| Crates.io | lilys-new-macro |
| lib.rs | lilys-new-macro |
| version | 0.1.1 |
| created_at | 2025-03-11 04:49:18.941574+00 |
| updated_at | 2025-03-15 06:35:56.834874+00 |
| description | Macro for generating a 'new' constructor function |
| homepage | |
| repository | https://github.com/jmeaster30/new-macro |
| max_upload_size | |
| id | 1587535 |
| size | 20,551 |
This is a macro to automate creating a 'new' function for structs
Here is a basic sample of the macro in action!
use new_macro::New;
#[derive(New)]
struct Test {
a: i32,
#[default(a * 2)]
b: i32,
}
struct Test {
a: i32,
b: i32,
}
impl Test {
pub fn new(a: i32) -> Self {
Self {
a,
b: a * 2,
}
}
}