Skip to content

Commit 60ed1e7

Browse files
authored
Redesign From derive macro (#241)
Replace `#[from(types(i32, "&str"))]` with `#[from(i32, &str)]` and add support for deriving multi-field structs and enum variants with `#[from((<tuple>), (<tuple>), ...)]`.
1 parent bc732a4 commit 60ed1e7

26 files changed

+3058
-752
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3131
- The `From` derive doesn't derive `From<()>` for enum variants without any
3232
fields anymore. This feature was removed because it was considered useless in
3333
practice.
34+
- The `From` derive now uses `#[from(<types>)]` instead of `#[from(types(<types>))]`
35+
and ignores field type itself.
3436

3537
### Added
3638

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ rustc_version = { version = "0.4", optional = true }
3333

3434
[dev-dependencies]
3535
rustversion = "1.0"
36+
static_assertions = "1.1"
3637
trybuild = "1.0.56"
3738

3839
[badges]
@@ -229,7 +230,7 @@ required-features = ["try_unwrap"]
229230
[[test]]
230231
name = "compile_fail"
231232
path = "tests/compile_fail/mod.rs"
232-
required-features = ["debug", "display"]
233+
required-features = ["debug", "display", "from"]
233234

234235
[[test]]
235236
name = "no_std"

0 commit comments

Comments
 (0)