@@ -129,7 +129,7 @@ use crate::ops::ControlFlow;
129
129
#[ doc( alias = "?" ) ]
130
130
#[ lang = "Try" ]
131
131
#[ const_trait]
132
- pub trait Try : FromResidual {
132
+ pub trait Try : ~ const FromResidual {
133
133
/// The type of the value produced by `?` when *not* short-circuiting.
134
134
#[ unstable( feature = "try_trait_v2" , issue = "84277" ) ]
135
135
type Output ;
@@ -438,10 +438,11 @@ where
438
438
/// and in the other direction,
439
439
/// `<Result<Infallible, E> as Residual<T>>::TryType = Result<T, E>`.
440
440
#[ unstable( feature = "try_trait_v2_residual" , issue = "91285" ) ]
441
+ #[ const_trait]
441
442
pub trait Residual < O > {
442
443
/// The "return" type of this meta-function.
443
444
#[ unstable( feature = "try_trait_v2_residual" , issue = "91285" ) ]
444
- type TryType : Try < Output = O , Residual = Self > ;
445
+ type TryType : ~ const Try < Output = O , Residual = Self > ;
445
446
}
446
447
447
448
#[ unstable( feature = "pub_crate_should_not_need_unstable_attr" , issue = "none" ) ]
@@ -460,14 +461,17 @@ pub(crate) struct NeverShortCircuit<T>(pub T);
460
461
impl < T > NeverShortCircuit < T > {
461
462
/// Wrap a binary `FnMut` to return its result wrapped in a `NeverShortCircuit`.
462
463
#[ inline]
463
- pub fn wrap_mut_2 < A , B > ( mut f : impl FnMut ( A , B ) -> T ) -> impl FnMut ( A , B ) -> Self {
464
- move |a, b| NeverShortCircuit ( f ( a, b) )
464
+ pub const fn wrap_mut_2_imp < A , B , F : ~const FnMut ( A , B ) -> T > (
465
+ f : & mut F ,
466
+ ( a, b) : ( A , B ) ,
467
+ ) -> NeverShortCircuit < T > {
468
+ NeverShortCircuit ( f ( a, b) )
465
469
}
466
470
}
467
471
468
472
pub ( crate ) enum NeverShortCircuitResidual { }
469
473
470
- impl < T > Try for NeverShortCircuit < T > {
474
+ impl < T > const Try for NeverShortCircuit < T > {
471
475
type Output = T ;
472
476
type Residual = NeverShortCircuitResidual ;
473
477
@@ -482,14 +486,14 @@ impl<T> Try for NeverShortCircuit<T> {
482
486
}
483
487
}
484
488
485
- impl < T > FromResidual for NeverShortCircuit < T > {
489
+ impl < T > const FromResidual for NeverShortCircuit < T > {
486
490
#[ inline]
487
491
fn from_residual ( never : NeverShortCircuitResidual ) -> Self {
488
492
match never { }
489
493
}
490
494
}
491
495
492
- impl < T > Residual < T > for NeverShortCircuitResidual {
496
+ impl < T > const Residual < T > for NeverShortCircuitResidual {
493
497
type TryType = NeverShortCircuit < T > ;
494
498
}
495
499
0 commit comments