lilys-new-macro

Crates.iolilys-new-macro
lib.rslilys-new-macro
version0.1.1
created_at2025-03-11 04:49:18.941574+00
updated_at2025-03-15 06:35:56.834874+00
descriptionMacro for generating a 'new' constructor function
homepage
repositoryhttps://github.com/jmeaster30/new-macro
max_upload_size
id1587535
size20,551
Lily Easterday (jmeaster30)

documentation

README

new-macro

This is a macro to automate creating a 'new' function for structs

Crates.io Version Run tests uwu

Examples

Here is a basic sample of the macro in action!

Source Code:

use new_macro::New;
#[derive(New)]
struct Test {
    a: i32,
    #[default(a * 2)]
    b: i32,
}

Generated Code:

struct Test {
    a: i32,
    b: i32,
}

impl Test {
    pub fn new(a: i32) -> Self {
      Self {
        a,
        b: a * 2,
      }
    }
}
Commit count: 16

cargo fmt