component_model 0.17.0

Revolutionary type-safe component assignment for Rust. Build complex objects with zero boilerplate using derive macros and type-driven field setting. Perfect for configuration builders, fluent APIs, and object composition patterns.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

#[ test ]
fn from_components()
{

  // o2: Options2 = o1.into()

  let o1 = Options1 { field1: 42, field2: "Hello, world!".to_string(), field3: 13.01 };
  let o2: Options2 = Into :: < Options2 > ::into( &o1 );
  let exp = Options2 { field1: 42, field2: "Hello, world!".to_string() };
  assert_eq!( o2, exp );
  let o2: Options2 = (&o1).into();
  assert_eq!( o2, exp );

}