Procedural macros to derive std::convert::From
and std::convert::Into
implementations based on field/variant names.
The crate supports struct
s and enum
s only. union
s are not supported.
From
```rust struct Point2D { x: i32, y: i32, }
struct Vec2D { x: i32, y: i32, }
let point = Point2D { x: 3, y: 4 };
let vector = Vec2D::from(point); // from
is derived
assert_eq!(vector, Vec2D { x: 3, y: 4 });
```
Into
```rust
struct Point2D { x: i32, y: i32, }
struct Vec2D { x: i32, y: i32, }
let point = Point2D { x: 3, y: 4 }; let vector: Vec2D = point.into(); assert_eq!(vector, Vec2D { x: 3, y: 4 }); ```