Hello world! RustLang rookie here, with a strong Java background.
I wish to find out if it's possible to get all the individual members of a struct through a simple assignment.
#[derive(Default, Debug)]
pub struct Rect {
pub len: usize,
pub width: usize,
}
fn main() {
// I tried this:
let (len, width) = Rect::default();
println!("LENGTH: {}", len);
println!("WIDTH: {}", width);
}
Error generated:
expected struct `Rect`, found tuple
Is there a way to automatically assign struct members to variables in a single statement. Or does this apply only to tuples?