1 unstable release
0.1.0 | Jan 5, 2019 |
---|
#103 in #tuple
5KB
as_tuple
View any struct as a tuple! ✨
[dependencies]
as_tuple = "0.1"
use as_tuple::AsTuple;
#[derive(AsTuple, Debug)]
struct Position {
x: f32,
y: f32,
}
let mut position = Position { x: 6.2, y: 4.3 };
let (x, y) = position.as_tuple_mut();
*x -= 1.0;
*y += 1.0;
println!("{:#?}", position);
(You can try it with cargo run --example position
)
lib.rs
:
View any struct as a tuple! ✨
See AsTuple
for usage info.
Dependencies
~2MB
~46K SLoC