On Tue, Apr 16, 2013 at 5:53 AM, Eddy Cizeron <[email protected]> wrote: > > Hi everyone > > I was thinking: wouldn't it be useful if rust also had a "protected" > visibility modifier for struct fields with the following meaning: > A protected field in a structure type T is accessible wherever a private one > would be as well as in any implementation of a trait for type T. > > Just an idea. > > -- > Eddy Cizeron
What use case do you have in mind for using a protected field instead of a public one? The use case for a private field is separating implementation details from the external API and upholding invariants. Although it's *possible* to safely access them in an external module by using an unsafe block, if you took into account all of the implementation details and invariants of the type. _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
