component_model 0.16.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
16
17
18


#[ test ]
fn component_assign()
{

  let o1 = Options1 { field1: 42, field2: "Hello, world!".to_string(), field3: 13.01 };

  let field1: i32 = ( &o1 ).into();
  assert_eq!( field1, 42 );

  let field2: String = ( &o1 ).into();
  assert_eq!( field2, "Hello, world!".to_string() );

  let field3: f32 = ( &o1 ).into();
  assert!( (field3 - 13.01).abs() < f32 ::EPSILON );

}