Commit dba9cdf
committed
Make bool::then_some and bool::then const methods
This change makes both `then_some` and `then` methods on bool const-compatible,
allowing them to be used in const contexts for compile-time evaluation.
Benefits:
- Enables compile-time conditional Option creation
- Allows usage in const generics and static initialization
- Provides zero-cost abstraction in const contexts
- Improves ergonomics for const programming patterns
The `then_some` method is straightforward to make const as it only uses
basic conditional logic. The `then` method requires a `~const FnOnce`
bound to ensure the closure can be called in const contexts.
This resolves the FIXME in the test suite and enables the const tests
for these methods that were previously disabled.1 parent 8b6b15b commit dba9cdf
2 files changed
+5
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
93 | 92 | | |
94 | 93 | | |
95 | 94 | | |
| |||
103 | 102 | | |
104 | 103 | | |
105 | 104 | | |
106 | | - | |
107 | 105 | | |
108 | 106 | | |
109 | 107 | | |
| |||
0 commit comments