new_derivable

Crates.ionew_derivable
lib.rsnew_derivable
version0.2.0
sourcesrc
created_at2022-01-30 19:46:49.122194
updated_at2022-01-30 21:18:16.521449
descriptionCreate new implementations with just a paste of a macro
homepage
repositoryhttps://github.com/ibx34/new_derivable
max_upload_size
id524171
size23,853
Shadow Wizurd Money Gang Leader (ibx34)

documentation

README

New Derivable

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
}
Commit count: 0

cargo fmt