You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, please allow making new private even for public structs/enums.
In several of my use cases I only intend to call the derived new internally, and I get this error:
error: private type in public interface. can't leak private type
Because the derived new takes as arg a private type, to initialize a private member.
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
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:
The text was updated successfully, but these errors were encountered: