-
Notifications
You must be signed in to change notification settings - Fork 183
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
Document traits as either sealed or implementable #4338
Comments
We need to decide both for CldrCalendar specifically and the language/code for the more general case. Assigned to @Manishearth for the purpose of making a proposal. |
For sealing traits I would suggest that we just use the typical If we need a trait to be implementable across crate boundaries, the For CldrCalendar specifically I think we should seal it and mark every method as Approval: |
I like the overall shape of this. Question: when you say "use the typical I remain concerned with the proliferation of
For the question in this thread, I am LGTM to make cross-crate-boundary-implementable sealed traits be "marked as internal using a convention which we decide elsewhere", not specifically |
One per crate, does not matter where it lives because it is private. And yes, it is just not exported.
Yeah I think so. Though we have a lot of internal APIs we need to unconditionally make public like provider APIs.
Worth considering using document-private-items.
To be clear, I'm only suggestion |
@sffc quick ping on approving this or moving the discussion forward |
Yeah I approve and have already been doing this for example in the |
@sffc thinking about this more: I don't think we should actually do this: these traits aren't implementable anyway, and we shouldn't scare people off from using APIs that use this traits. Rather, I recommend having text of the form ":no_entry_sign: This trait is sealed and cannot be implemented in userland code" |
What I ended up doing in datetime is export a trait called |
https://unicode-org.github.io/icu4x/rustdoc/icu_datetime/scaffold/trait.UnstableSealed.html That particular name might be reasonable to use as a standard name elsewhere, too. |
@sffc yeah, but in this issue we agreed to just seal it, so we don't need UnstableSealed anymore |
I'm scrolling and I'm not sure what the agreement is? I said in #4338 (comment) that I agreed to the proposal in #4338 (comment) conditional on the decision in #4467, because I do not want a proliferation of Since I said that, there has not been much movement on |
In most cases I've seen, there's no reason to seal traits other than us reserving the right to change them. However, in many cases, even in datetime, I want to retain the ability to build custom implementations of certain traits in third-party code; if someone wants to do something that ICU4X can't do by itself, I want to have as many knobs available as possible. Only when there are actual safety invariants involved do I see a reason for the traits to actually be private-sealed. I don't see a use case behind doc-hidden sealed. |
I agree on Or we just say that the |
That's the agreement^ I think I know what happened here: CldrCalendar uses UnstableSealed, but so does everything else in the crate. I mistakenly took the agreement above to mean that datetime should use Sealed everywhere, but it's just CldrCalendar that does that. Everything else in the crate should use UnstableSealed. I'll redo my PR. I don't think we should proliferate the UnstableSealed pattern unless there's a strong reason. The "slab of docs" you proposed makes sense for UnstableSealed, not regular Sealed.
yes, this is what I mean by "doc hidden sealed"
Is the main problem just ICU4X dev discovery? We can publish docs with |
Anyway, here's what I plan to do tomorrow:
|
Just like we document structs and enums as either exhaustive or non-exhaustive, we should document traits as either sealed or implementable.
For sealed traits, we could add a
__sealed()
function, and add a slab like this to the docs:Unclear if there is a Clippy lint to enforce this.
The text was updated successfully, but these errors were encountered: