-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add const fn none() #27
Conversation
Related questions:
My motivation: what I actually want is to represent the last time something happened, if any. |
Thanks! Seems reasonable to have such a feature.
Given that these types already have some associated constants, associated constants may be more consistent. That said, I have no strong opinion on this.
It is interesting that associated constants are less flexible than const fns, but I'm not too worried about this as we can define an associated constant using a private const fn.
The first purpose of this crate was to use
Sorry, I'm not sure what you mean. The current |
Both types have an But in that case, I guess this crate is redundant since rust-lang/rust#89926 ? |
dtolnay/request-for-implementation#27 and rust-lang/rust#58395 are the context of this crate. I agree that (EDIT: To clarify, I'm not negative at all about the other use cases. I'm just concerned about a potential pitfall of the API for known use cases.)
Well, that PR fixes the most annoying problem, but they are not the only operations that cause panic. |
Updated. I probably won't end up using this library myself, so leave it to you to decide what to do with this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
Build succeeded: |
Published in 0.2.3. |
Both
Duration
andInstant
are explicitly optional types, so why not add this?Alternative: add
NONE
as an associated constant. Simpler, but less flexible in case the internal representation changes.Workaround: both support
From<Option<..>>
already.