constify boolean methods#151489
Conversation
There was a problem hiding this comment.
Personally, I prefer the name const_bool_ops for this feature gate.
It would be nice if you could also remove the FIXME and enable these tests for const.
rust/library/coretests/tests/bool.rs
Lines 85 to 107 in d29e478
This comment has been minimized.
This comment has been minimized.
fec2775 to
06a0024
Compare
|
My understanding is we're in the "constify everything" phase, so feel free to create a tracking issue. Let me know when that's done (and the PR updated with the issue number) and I'll approve it. @rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
| #[test] | ||
| fn test_bool_to_result() { | ||
| assert_eq!(false.ok_or(0), Err(0)); | ||
| assert_eq!(true.ok_or(0), Ok(())); | ||
| assert_eq!(false.ok_or_else(|| 0), Err(0)); | ||
| assert_eq!(true.ok_or_else(|| 0), Ok(())); | ||
| } |
There was a problem hiding this comment.
Could you also add some const test cases for ok_or ok_or_else here? Like the ones above. I forgot to say it yesterday, sorry 😅
06a0024 to
bbef137
Compare
This comment has been minimized.
This comment has been minimized.
bbef137 to
207dcbb
Compare
|
@rustbot ready |
|
Thanks! @bors r+ rollup |
…s-under-feature-gate-const-bool, r=jhpratt
constify boolean methods
```rs
// core::bool
impl bool {
pub const fn then_some<T: [const] Destruct>(self, t: T) -> Option<T>;
pub const fn then<T, F: [const] FnOnce() -> T + [const] Destruct>(self, f: F) -> Option<T>;
pub const fn ok_or<E: [const] Destruct>(self, err: E) -> Result<(), E>;
pub const fn ok_or_else<E, F: [const] FnOnce() -> E + [const] Destruct>;
}
```
will make tracking issue if pr liked
Rollup of 8 pull requests Successful merges: - #150556 (Add Tier 3 Thumb-mode targets for Armv7-A, Armv7-R and Armv8-R) - #151346 (add `simd_splat` intrinsic) - #151500 (hexagon: Add HVX target features) - #151505 (Various refactors to the proc_macro bridge) - #151517 (Enable reproducible binary builds with debuginfo on Linux) - #151482 (Add "Skip to main content" link for keyboard navigation in rustdoc) - #151489 (constify boolean methods) - #151551 (Don't use default build-script fingerprinting in `test`) r? @ghost
…s-under-feature-gate-const-bool, r=jhpratt
constify boolean methods
```rs
// core::bool
impl bool {
pub const fn then_some<T: [const] Destruct>(self, t: T) -> Option<T>;
pub const fn then<T, F: [const] FnOnce() -> T + [const] Destruct>(self, f: F) -> Option<T>;
pub const fn ok_or<E: [const] Destruct>(self, err: E) -> Result<(), E>;
pub const fn ok_or_else<E, F: [const] FnOnce() -> E + [const] Destruct>;
}
```
will make tracking issue if pr liked
Rollup of 8 pull requests Successful merges: - #150556 (Add Tier 3 Thumb-mode targets for Armv7-A, Armv7-R and Armv8-R) - #151500 (hexagon: Add HVX target features) - #151505 (Various refactors to the proc_macro bridge) - #151517 (Enable reproducible binary builds with debuginfo on Linux) - #151482 (Add "Skip to main content" link for keyboard navigation in rustdoc) - #151489 (constify boolean methods) - #151551 (Don't use default build-script fingerprinting in `test`) - #151555 (Fix compilation of std/src/sys/pal/uefi/tests.rs) r? @ghost
…s-under-feature-gate-const-bool, r=jhpratt
constify boolean methods
```rs
// core::bool
impl bool {
pub const fn then_some<T: [const] Destruct>(self, t: T) -> Option<T>;
pub const fn then<T, F: [const] FnOnce() -> T + [const] Destruct>(self, f: F) -> Option<T>;
pub const fn ok_or<E: [const] Destruct>(self, err: E) -> Result<(), E>;
pub const fn ok_or_else<E, F: [const] FnOnce() -> E + [const] Destruct>;
}
```
will make tracking issue if pr liked
…uwer Rollup of 8 pull requests Successful merges: - #150556 (Add Tier 3 Thumb-mode targets for Armv7-A, Armv7-R and Armv8-R) - #151259 (Fix is_ascii performance regression on AVX-512 CPUs when compiling with -C target-cpu=native) - #151500 (hexagon: Add HVX target features) - #151517 (Enable reproducible binary builds with debuginfo on Linux) - #151482 (Add "Skip to main content" link for keyboard navigation in rustdoc) - #151489 (constify boolean methods) - #151551 (Don't use default build-script fingerprinting in `test`) - #151555 (Fix compilation of std/src/sys/pal/uefi/tests.rs) r? @ghost
Rollup merge of #151489 - bend-n:constify-all-boolean-methods-under-feature-gate-const-bool, r=jhpratt constify boolean methods ```rs // core::bool impl bool { pub const fn then_some<T: [const] Destruct>(self, t: T) -> Option<T>; pub const fn then<T, F: [const] FnOnce() -> T + [const] Destruct>(self, f: F) -> Option<T>; pub const fn ok_or<E: [const] Destruct>(self, err: E) -> Result<(), E>; pub const fn ok_or_else<E, F: [const] FnOnce() -> E + [const] Destruct>; } ``` will make tracking issue if pr liked
will make tracking issue if pr liked