File tree 3 files changed +6
-26
lines changed
3 files changed +6
-26
lines changed Original file line number Diff line number Diff line change @@ -436,20 +436,6 @@ const _: () = Ok::<(), ()>(()).expect("");
436
436
```
437
437
438
438
439
- ### ` [tag:const_result_ok] ` ` Result::ok ` is not ` const fn `
440
-
441
- * Upstream PR:* [ rust-lang/rust #92385 ] ( https://github.com/rust-lang/rust/pull/92385 ) will unstably add this
442
-
443
- ``` rust
444
- Ok :: <(), ()>(()). ok ();
445
- ```
446
-
447
- ``` rust,compile_fail,E0015
448
- // error[E0015]: cannot call non-const fn `Result::<(), ()>::ok` in constants
449
- const _: () = { Ok::<(), ()>(()).ok(); };
450
- ```
451
-
452
-
453
439
### ` [tag:const_result_map] ` ` Result::map[_err] ` is not ` const fn `
454
440
455
441
``` rust
Original file line number Diff line number Diff line change 24
24
#![ feature( const_refs_to_cell) ]
25
25
#![ feature( maybe_uninit_slice) ]
26
26
#![ feature( const_nonnull_new) ]
27
+ #![ feature( const_result_drop) ]
27
28
#![ feature( const_impl_trait) ]
28
29
#![ feature( const_option_ext) ]
29
30
#![ feature( const_ptr_offset) ]
Original file line number Diff line number Diff line change @@ -140,9 +140,11 @@ impl Time {
140
140
/// `None` if the result overflows the representable range of `Duration`.
141
141
#[ inline]
142
142
pub const fn duration_since ( self , reference : Self ) -> Option < Duration > {
143
- Some ( Duration :: from_micros ( result_ok (
144
- ( self . micros as i128 - reference. micros as i128 ) . try_into ( ) ,
145
- ) ?) )
143
+ Some ( Duration :: from_micros (
144
+ ( self . micros as i128 - reference. micros as i128 )
145
+ . try_into ( )
146
+ . ok ( ) ?,
147
+ ) )
146
148
}
147
149
148
150
/// Advance the time by `duration` and return the result.
@@ -278,12 +280,3 @@ impl TryFrom<Time> for chrono_0p4::DateTime<chrono_0p4::Utc> {
278
280
}
279
281
280
282
// TODO: Add more tests
281
-
282
- /// Polyfill for `[ref:const_result_ok]`
283
- #[ inline]
284
- const fn result_ok < T , E : ~const Drop > ( x : Result < T , E > ) -> Option < T > {
285
- match x {
286
- Ok ( x) => Some ( x) ,
287
- Err ( _x) => None ,
288
- }
289
- }
You can’t perform that action at this time.
0 commit comments