generic-new
[](https://crates.io/crates/generic-new)
[](https://docs.rs/generic-new)
[](https://github.com/aatifsyed/generic-new)
A derive macro which generates an ergonomic constructor with shortcuts for certain types.
```rust
use generic_new::GenericNew;
[derive(GenericNew)]
struct Foo {
s: String, // -> impl AsRef
v: Vec, // -> impl IntoIterator-
p: PathBuf, // -> impl AsRef
#[genericnew(ignore)]
i: String, // Turn off magic conversion for some fields
#[genericnew(ty = impl Into, converter = |u|Into::into(u))]
u: usize, // Custom converters are supported
}
Foo::new(
"hello",
[1, 2, 3],
"path/to/foo",
String::from("world"),
1u16,
);
```
License: MIT