Crates.io | as_tuple |
lib.rs | as_tuple |
version | 0.1.0 |
source | src |
created_at | 2019-01-05 01:46:41.774554 |
updated_at | 2019-01-05 01:46:41.774554 |
description | View any struct as a tuple! ✨ |
homepage | |
repository | https://github.com/francesca64/as_tuple |
max_upload_size | |
id | 105570 |
size | 4,906 |
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
)