Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upEnumerate the circumstances in which private in public is acceptable #73
Comments
This comment has been minimized.
This comment has been minimized.
|
Another case to consider here: impl From<InternalFrom<Error>> for ErrorThe InternalFrom type is private but this is an implementation of a public trait so it is part of the public API. Maybe this is fine but then rustdoc should not show this impl. |
This comment has been minimized.
This comment has been minimized.
|
I would like to propose that if a public trait has a private super trait, then:
The name The other two points do not affect the API so I guess they don't belong in API guidelines, but they make this confusing pattern easier to see and understand when reading code. |
This comment has been minimized.
This comment has been minimized.
|
Public trait implementations that are not intended to be available to users, like |
dtolnay commentedMay 27, 2017
In
serde_json::value::Indexthere is a private supertrait to seal the trait and allow it to evolve as needed. This is an acceptable use.In
reqwest::RedirectPolicy::customtheRedirectAttemptfrom the function signature is private, which forces the user to express their redirect policy as a closure. There is no way they can factor it out into a function. This seems unnecessary.