| Crates.io | new_derivable |
| lib.rs | new_derivable |
| version | 0.2.0 |
| created_at | 2022-01-30 19:46:49.122194+00 |
| updated_at | 2022-01-30 21:18:16.521449+00 |
| description | Create new implementations with just a paste of a macro |
| homepage | |
| repository | https://github.com/ibx34/new_derivable |
| max_upload_size | |
| id | 524171 |
| size | 23,853 |
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
}