3个版本

0.1.2 2019年12月12日
0.1.1 2019年12月11日
0.1.0 2019年12月6日

#newtype中排名58

Apache-2.0 OR MIT

9KB
88

from_tuple

为具有唯一字段类型的结构体推导From元组。因为所有字段类型都必须是唯一的,所以它对于使用newtype模式来定义其字段的结构体非常有用。

FromTuple文档页面上找到更多信息。

示例

use from_tuple::FromTuple;

#[derive(FromTuple)]
struct Hello {
    message: String,
    time: i32,
    counter: usize
}

fn main() {
    let hello: Hello = (-42, "hi".to_string(), 0usize).into();

    assert_eq!(&hello.message, "hi");
    assert_eq!(hello.time, -42);
    assert_eq!(hello.counter, 0);
}

许可证

许可协议为以下之一

任选其一。

贡献

除非您明确声明,否则您根据Apache-2.0许可证定义的任何有意提交以包含在此项目中的贡献,将根据上述方式双许可,不附加任何额外条款或条件。

依赖关系

~1.5MB
~36K SLoC