4个版本
| 0.0.4 | 2023年7月25日 |
|---|---|
| 0.0.3 | 2023年4月2日 |
| 0.0.2 | 2021年12月19日 |
| 0.0.1 | 2021年12月19日 |
362 in 过程宏
11KB
242 行
按名称转换
基于字段/变体名称派生core::convert::From和core::convert::Into实现的程序宏。该Crate仅支持struct和enum。不支持union。
示例
#[derive(PartialEq, Debug)]
struct Point2D {
x: i32,
y: i32,
}
#[derive(PartialEq, Debug, ConvertByName)]
#[from(Point2D)]
#[into(Point2D)]
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 });
let point2: Point2D = vector.into();
assert_eq!(point2, Point2D { x: 3, y: 4 });
lib.rs:
基于字段/变体名称派生core::convert::From和core::convert::Into实现的程序宏。
依赖项
~290–740KB
~18K SLoC