New Derivable
Automatically create a new implementation for your Structs (Unnamed, and Named).
use New;
will ceate
so then you can do
Which will give us
Human
Automatically create a new implementation for your Structs (Unnamed, and Named).
use new_derivable::New;
#[derive(New,Debug)]
pub struct Human {
pub name: String,
pub age: i64
}
will ceate
impl Human {
fn new(name: String, age: i64) -> Self {
Self { name, age }
}
}
so then you can do
fn main() {
let human = Human::new(String::from("Justin"),69);
println!("{:#?}", human);
}
Which will give us
Human {
name: "Justin",
age: 69
}