I ran across this and found it strange. That I can
impl a type defined in the same crate in a different file but I cannot access private fields (in an impl or a trait impl for that type). I know that it is possible to change the “public” nature of a struct (for instance using
pub(super)) but that makes the private fields accessible in that place for all functions, not just impl’s.
Maybe I don’t quite understand what rust’s meaning of private/public is. But after searching around I could neither find that answer or find an answer as to why this was the way it was.
Private member fields should be accessible in
impl blocks associated with that type.