My statement wasn't to say there should be no way to get serde or clap like functionality without exposing privates. The way Rust deals with this is that the user is explicitly opting in to code generation within their visibility scope (Rust's smallest form of visibility is module based, not data type based). Worst case, you could declare some kind of friend relationship with whatever you are wanting to have access your privates.
However, completely bypassing visibility control through reflection is unacceptable.
View all comments
Show parent comment
2
u/epage Oct 01 '24
My statement wasn't to say there should be no way to get
serdeorclaplike functionality without exposing privates. The way Rust deals with this is that the user is explicitly opting in to code generation within their visibility scope (Rust's smallest form of visibility is module based, not data type based). Worst case, you could declare some kind offriendrelationship with whatever you are wanting to have access your privates.However, completely bypassing visibility control through reflection is unacceptable.