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
Tracking issue for const Option
functions
#67441
Comments
Make some Option methods const Tracking issue: rust-lang#67441 Constantify the following methods of `Option`: - `as_ref` - `is_some` - `is_none` - `iter` (not sure about this one, but it is possible, and will be useful when const traits are a thing) cc @rust-lang/wg-const-eval @rust-lang/libs
Make some Option methods const Tracking issue: rust-lang#67441 Constantify the following methods of `Option`: - `as_ref` - `is_some` - `is_none` - `iter` (not sure about this one, but it is possible, and will be useful when const traits are a thing) cc @rust-lang/wg-const-eval @rust-lang/libs
…=oli-obk Make `Option::unwrap` unstably const This is lumped into the `const_option` feature gate (rust-lang#67441), which enables a potpourri of `Option` methods. cc @rust-lang/wg-const-eval r? @oli-obk
Stabilize some Option methods as const Stabilize the following methods of `Option` as const: - `is_some` - `is_none` - `as_ref` These methods are currently const under the unstable feature `const_option` (tracking issue: rust-lang#67441). I believe these methods to be eligible for stabilization because of the stabilization of rust-lang#49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](rust-lang#75463). Related: rust-lang#76225
Stabilize some Option methods as const Stabilize the following methods of `Option` as const: - `is_some` - `is_none` - `as_ref` These methods are currently const under the unstable feature `const_option` (tracking issue: rust-lang#67441). I believe these methods to be eligible for stabilization because of the stabilization of rust-lang#49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](rust-lang#75463). Related: rust-lang#76225
Yes for constantifying However, as per https://doc.rust-lang.org/nightly/src/core/option.rs.html,
Since that is not specific to |
@peter-kehl the tracking issue for panicking in constants is #51999 |
FYI anyone looking at I wonder if it would be feasible for the compiler to allow use of |
@davidhewitt Given that neither const trait impls nor const trait bounds are usable on stable, it would be quite unintuitive if this were. Even on nightly, const traits have yet to be RFC accepted. |
Sorry, I typo'd above - I meant to say only allow types which don't We probably wouldn't want this in the function signature (should just be TBH it sounds messy and slightly leaks information about the function implementation, so I'm unconvinced it's worth the effort. Just musing of a way to allow some forms of const |
Yeah, I figured it was a typo and responded accordingly. I still think it would be awkward to have this magically work for some types but not others, especially if this isn't in the function signature. I'd much rather wait for const trait impls to be RFC approved and land on stable, as that would allow way more than just this. Just look at the blockers on #82814 and realize that having const trait impls would allow ~80% of them (just guessing, I haven't bothered to actually calculate a percentage). |
If/when #51999 is stabilized, |
@jhpratt |
Can @9999years add these to the list at the top? |
…-replace, r=joshtriplett const fn for option copied, take & replace Tracking issue: [rust-lang#67441](rust-lang#67441) Adding const fn for the copied, take and replace method of Option. Also adding necessary unit test. It's my first contribution so I am pretty sure I don't know what I'm doing but there's a first for everything!
…-replace, r=joshtriplett const fn for option copied, take & replace Tracking issue: [rust-lang#67441](rust-lang#67441) Adding const fn for the copied, take and replace method of Option. Also adding necessary unit test. It's my first contribution so I am pretty sure I don't know what I'm doing but there's a first for everything!
Make Option::as_mut const Adding `const` for `Option::as_mut`. Tracking issue: rust-lang#67441
Make Option::as_mut const Adding `const` for `Option::as_mut`. Tracking issue: rust-lang#67441
|
Since the panic now seems to support non-const strings as second argument, |
@CodesInChaos I believe it's blocked on |
Make `Option::expect` unstably const Tracking issue: rust-lang#67441
Make `Option::expect` unstably const Tracking issue: rust-lang#67441
|
unstably for those not looking in further detail ^^ |
Was there any actual blocker to stabilising |
Precise live drops (or whatever it's called) is the sole blocker to my knowledge. |
AFAICT, little progress were made since #73255 (comment) so I guess stabilization is likely going to take some time. |
Current candidates with
feature = const_option
includeis_some
,is_none
as_ref
expect
unwrap_or
,Requires Calling methods on generic parameters of const fns rfcs#2632 to use functional interfaces (in specific, trait bounds on generic fns).unwrap_or_else
ok_or
,ok_or_else
and
,and_then
filter
or
,or_else
xor
transpose
flatten
See also the meta-tracking issue for const fns, #57563.
Working on this in PR #66884.
Blocked on #73255.
The text was updated successfully, but these errors were encountered: