Unimplementable ("Sealed") Traits
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
Hi,
a lot of times you want to have a trait in your library/crate that can't be implemented by the library users.
either because it's a marker trait for FFI related things, related to a custom type system, or because it's very highly unsafe and weird.
libstd's solution to this problem is exposing pub traits but marking them unstable to implement i.e. https://doc.rust-lang.org/std/slice/trait.SliceIndex.html
I propose we add something like #[non_exhaustive] but for traits, i.e. #[unimplementable]
we can already see similiar weird tricks in the wild, i.e.
https://docs.rs/zerocopy/0.2.8/src/zerocopy/lib.rs.html#207
https://github.com/rust-bitcoin/rust-secp256k1/blob/master/src/context.rs#L10
and more.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue discussion and the linked SliceIndex, zerocopy, and rust-secp256k1 examples. Compare how each prevents downstream implementations, then specify the proposed attribute's semantics and unresolved trade-offs through the RFC process; done means the design is sufficiently detailed for review.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100