Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private supertrait pattern #16

Closed
dtolnay opened this issue Apr 4, 2017 · 3 comments
Closed

Private supertrait pattern #16

dtolnay opened this issue Apr 4, 2017 · 3 comments
Labels
important new guideline A proposed new guideline

Comments

@dtolnay
Copy link
Member

dtolnay commented Apr 4, 2017

This pattern is a way to retain the ability to add/remove/modify methods of a public trait without breaking compatibility. Example from byteorder: BurntSushi/byteorder#69.

@dtolnay
Copy link
Member Author

dtolnay commented Sep 18, 2017

Relevant discussion in the context of Hyper: hyperium/hyper#1194

@dtolnay dtolnay added the new guideline A proposed new guideline label Sep 18, 2017
@dtolnay
Copy link
Member Author

dtolnay commented Oct 29, 2017

Added in e7d7202.

@dtolnay dtolnay closed this as completed Oct 29, 2017
@matklad
Copy link
Member

matklad commented Jul 4, 2018

@dtolnay curious, why we put #[doc(hidden)] on the methods of the public trait, if we can just add these methods to the private counterpart? That is, something like this should work?

I don't think that it matters much in practice, but doc(hidden) methods are still visible, and might cause ambiguous method calls in theory....

EDIT: nvm, methods of private supertraits are visible if you import the public trait: https://play.rust-lang.org/?gist=4cb854858e5cae10a25a40680d6a687c&version=stable&mode=debug&edition=2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
important new guideline A proposed new guideline
Projects
None yet
Development

No branches or pull requests

3 participants