Skip to content

Commit bbeb200

Browse files
authored
feat: implement a macro for trait transformations (#12)
2 parents 4182667 + e1d0ee6 commit bbeb200

File tree

85 files changed

+2092
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2092
-106
lines changed

.github/codecov.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
coverage:
2+
precision: 2
3+
round: down
4+
range: 70...90
5+
6+
status:
7+
project:
8+
default:
9+
enabled: true
10+
threshold: 1%

.github/workflows/cicd.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107

108108
- name: Check | Miri
109109
if: matrix.toolchain == 'nightly'
110-
run: cargo miri test --workspace --all-features
110+
run: cargo miri test -p dynify --all-features
111111

112112
- name: Check | Coverage
113113
if: matrix.toolchain == 'nightly'
@@ -125,9 +125,36 @@ jobs:
125125
files: lcov.info
126126
fail_ci_if_error: true
127127

128+
changelog:
129+
name: Update changelog
130+
needs: [check]
131+
if: github.event_name == 'pull_request'
132+
permissions:
133+
contents: write # need to commit changes
134+
runs-on: ubuntu-latest
135+
steps:
136+
- name: Setup | Checkout
137+
uses: actions/checkout@v4
138+
with: { ref: "${{ github.head_ref }}" }
139+
140+
- name: Doc | Update changelog
141+
run: |
142+
sed -i \
143+
-e 's/{{PRNUM}}/${{ github.event.number }}/g' \
144+
-e "s/{{DATE}}/$(date -u +'%Y-%m-%d')/g" \
145+
CHANGELOG.md
146+
147+
- name: Post Doc | Commit changes
148+
uses: stefanzweifel/git-auto-commit-action@v6
149+
with:
150+
commit_message: "docs: expand variables in changelog"
151+
commit_user_name: github-actions[bot]
152+
commit_user_email: github-actions[bot]@users.noreply.github.com
153+
commit_author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
154+
128155
release:
129156
name: Create GitHub release
130-
needs: [metadata, check]
157+
needs: [check, changelog]
131158
if: startsWith(github.head_ref, 'release/')
132159
permissions:
133160
contents: write # Need to update release

CHANGELOG.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
6-
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to
7+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
78

89
<!--
9-
Here's a template for each release section. This file should only include changes that are
10-
noticeable to end-users since the last release. For developers, this project follows
11-
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) to track changes.
10+
Here's a template for each release section. This file should only include updates
11+
that are noticeable to end users between two releases. For developers, this project
12+
follows <https://www.conventionalcommits.org/en/v1.0.0/> to track changes.
1213
1314
## [1.0.0] - YYYY-MM-DD
1415
1516
### Added
1617
17-
- (**BREAKING**) Always place breaking changes at the top.
18-
- Append other changes in chronological order under the relevant subsections.
18+
- (**breaking**) Always place breaking changes at the top of each subsection.
19+
- Append other changes in chronological order under the appropriate subsection.
20+
- Additionally, you may use `{{variable name}}` as a placeholder for the value
21+
of a named variable, which includes:
22+
- `PRNUM`: the number of the pull request
23+
- `DATE`: the date in `YYYY-MM-DD` format whenever the pull request is updated
1924
2025
### Changed
2126
@@ -36,14 +41,17 @@ noticeable to end-users since the last release. For developers, this project fol
3641

3742
- Support downcasting a `Buffered` pointer ([#10]).
3843
- Support unwrapping a `Buffered` pointer ([#11]).
44+
- Add a helper macro `#[dynify]` for trait transformations ([#12]).
3945

4046
[#10]: https://github.com/loichyan/dynify/pull/10
4147
[#11]: https://github.com/loichyan/dynify/pull/11
48+
[#12]: https://github.com/loichyan/dynify/pull/12
4249

4350
## [0.1.0] - 2025-07-06
4451

45-
The main purpose of this release is to address unsoundness and introduce breaking changes early to
46-
prevent further issues. Consequently, it includes few changes.
52+
The main purpose of this release is to address unsoundness and introduce
53+
breaking changes early to prevent further issues. Consequently, it includes few
54+
changes.
4755

4856
### Added
4957

@@ -56,8 +64,8 @@ prevent further issues. Consequently, it includes few changes.
5664

5765
### Removed
5866

59-
- (**BREAKING**) Remove `Emplace` implementations for `&mut [u8; N]`, `&mut [u8]` and `&mut Vec<u8>`
60-
([#2]).
67+
- (**breaking**) Remove `Emplace` implementations for `&mut [u8; N]`,
68+
`&mut [u8]` and `&mut Vec<u8>` ([#2]).
6169

6270
### Fixed
6371

@@ -70,8 +78,9 @@ prevent further issues. Consequently, it includes few changes.
7078

7179
## [0.0.1] - 2025-07-05
7280

73-
🎉 Initial release. Check out [README](https://github.com/loichyan/dynify/blob/v0.0.1/README.md) for
74-
more details.
81+
🎉 Initial release. Check out
82+
[README](https://github.com/loichyan/dynify/blob/v0.0.1/README.md) for more
83+
details.
7584

7685
[0.0.1]: https://github.com/loichyan/dynify/releases/tag/v0.0.1
7786
[0.1.0]: https://github.com/loichyan/dynify/releases/tag/v0.1.0

Cargo.lock

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,59 @@
1-
[package]
2-
name = "dynify"
3-
version = "0.1.0"
1+
[workspace]
2+
members = ["macros"]
3+
4+
[workspace.package]
45
authors = ["Loi Chyan <[email protected]>"]
56
license = "MIT OR Apache-2.0"
67
edition = "2021"
78
rust-version = "1.80"
8-
99
repository = "https://github.com/loichyan/dynify"
10-
description = "Add dyn compatible variant to you async trait"
10+
11+
[workspace.dependencies]
12+
fastrand = "2.3.0"
13+
rstest = { version = "0.25.0", default-features = false }
14+
15+
[workspace.lints.rust]
16+
unexpected_cfgs.level = "warn"
17+
unexpected_cfgs.check-cfg = ["cfg(coverage)", "cfg(coverage_nightly)"]
18+
unknown_lints = "allow"
19+
20+
[workspace.lints.clippy]
21+
uninlined_format_args = "allow"
22+
23+
[package]
24+
name = "dynify"
25+
version = "0.1.0"
26+
authors.workspace = true
27+
license.workspace = true
28+
edition.workspace = true
29+
rust-version.workspace = true
30+
31+
repository.workspace = true
32+
description = "Add dyn compatible variant to your async trait"
1133
keywords = ["async", "trait", "impl"]
1234
categories = ["asynchronous", "no-std", "rust-patterns"]
1335

1436
[features]
15-
default = ["alloc"]
37+
default = ["alloc", "macros"]
1638
alloc = []
39+
macros = ["dep:dynify-macros"]
1740
smallvec = ["dep:smallvec"]
1841

1942
[dependencies]
43+
dynify-macros = { path = "./macros", optional = true }
2044
smallvec = { version = "1", optional = true }
2145

2246
[dev-dependencies]
23-
fastrand = "2.3.0"
47+
fastrand.workspace = true
2448
pollster = { version = "0.4.0", features = ["macro"] }
25-
rstest = { version = "0.25.0", default-features = false }
49+
rstest.workspace = true
50+
rustversion = "1.0.21"
51+
trait-variant = "0.1.2"
2652
trybuild = "1.0.105"
2753

2854
[package.metadata.docs.rs]
2955
all-features = true
3056
rustdoc-args = ["--cfg", "docsrs"]
3157

32-
[lints.rust]
33-
unexpected_cfgs.level = "warn"
34-
unexpected_cfgs.check-cfg = ["cfg(coverage)", "cfg(coverage_nightly)"]
35-
unknown_lints = "allow"
36-
37-
[lints.clippy]
38-
uninlined_format_args = "allow"
58+
[lints]
59+
workspace = true

0 commit comments

Comments
 (0)