FullCtor

Derive Macro FullCtor 

Source
#[derive(FullCtor)]
Expand description

Generates a constructor method for a struct, allowing instantiation with all fields.

This procedural macro derives an implementation of a new method for a struct. The generated method takes each field of the struct as a parameter and returns an instance of the struct with those fields initialized.

§Example

use quick_macros::FullCtor;

#[derive(FullCtor)]
struct Person {
    name: String,
    age: u32,
}

let person = Person::new("Alice".to_string(), 30);
assert_eq!(person.name, "Alice");
assert_eq!(person.age, 30);

§Panics

  • If the macro is applied to a non-struct type (e.g., an enum or union), it will panic.