为枚举提供 derive 过程宏,用于实现 From 特性
作者:John Peel
#309 in 无标准库
3KB
它与 thiserror 的 #[from] 属性具有相同的接口,但可以在无标准库环境中工作。
#[from]
use from_enum::From; #[derive(From)] enum MyEnum { String(#[from] String), Int(#[from] i32), }
~1.5MB ~35K SLoC