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

Comments

Projects
None yet
3 participants
@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.

@brson brson added the important label Jun 30, 2017

@dtolnay

This comment has been minimized.

Copy link
Member Author

dtolnay commented Sep 18, 2017

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

@dtolnay

This comment has been minimized.

Copy link
Member Author

dtolnay commented Oct 29, 2017

Added in e7d7202.

@dtolnay dtolnay closed this Oct 29, 2017

@matklad

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.