Today, #[derive(new)] always creates a pub fn, regardless of the visibility of the struct it's applied to.
In Rust 2018, that becomes a lint error, which makes it (at present) difficult to use this crate in a crate with #[warn(rust_2018_idioms)].
Instead, the visibility of the new method should be the same as the visibility of the struct.
It might also be useful to allow the visibility to be controlled directly. Straw man:
#[derive(new)]
#[new(visibility = crate)]
struct Point {
x: u32,
y: u32,
}
Today,
#[derive(new)]always creates apub fn, regardless of the visibility of the struct it's applied to.In Rust 2018, that becomes a lint error, which makes it (at present) difficult to use this crate in a crate with
#[warn(rust_2018_idioms)].Instead, the visibility of the
newmethod should be the same as the visibility of the struct.It might also be useful to allow the visibility to be controlled directly. Straw man: