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

Consider restricting implementations of SizeLimit #141

Closed
dtolnay opened this issue Mar 21, 2017 · 0 comments
Closed

Consider restricting implementations of SizeLimit #141

dtolnay opened this issue Mar 21, 2017 · 0 comments
Milestone

Comments

@dtolnay
Copy link
Collaborator

@dtolnay dtolnay commented Mar 21, 2017

I don't think 1.0 should have a SizeLimit trait that allows external implementations until somebody proposes a really good use case for it. In serde_json we restrict implementations by using a private supertrait:

pub trait SizeLimit: private::Sealed {
    #[doc(hidden)]
    all the methods
}

mod private {
    pub trait Sealed {}
    impl Sealed for super::Infinite {}
    impl Sealed for super::Bounded {}
}

This allows adding / changing methods in the future as necessary without a major version bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.