Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/test-utils/src/minicore.rs')
-rw-r--r--crates/test-utils/src/minicore.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/crates/test-utils/src/minicore.rs b/crates/test-utils/src/minicore.rs
index 48c3e89525..5b9165d537 100644
--- a/crates/test-utils/src/minicore.rs
+++ b/crates/test-utils/src/minicore.rs
@@ -953,6 +953,9 @@ pub mod ops {
#[lang = "from_residual"]
fn from_residual(residual: R) -> Self;
}
+ pub const trait Residual<O>: Sized {
+ type TryType: [const] Try<Output = O, Residual = Self>;
+ }
#[lang = "Try"]
pub trait Try: FromResidual<Self::Residual> {
type Output;
@@ -962,6 +965,12 @@ pub mod ops {
#[lang = "branch"]
fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
}
+ #[lang = "into_try_type"]
+ pub const fn residual_into_try_type<R: [const] Residual<O>, O>(
+ r: R,
+ ) -> <R as Residual<O>>::TryType {
+ FromResidual::from_residual(r)
+ }
impl<B, C> Try for ControlFlow<B, C> {
type Output = C;
@@ -985,6 +994,10 @@ pub mod ops {
}
}
}
+
+ impl<B, C> Residual<C> for ControlFlow<B, Infallible> {
+ type TryType = ControlFlow<B, C>;
+ }
// region:option
impl<T> Try for Option<T> {
type Output = T;
@@ -1008,6 +1021,10 @@ pub mod ops {
}
}
}
+
+ impl<T> const Residual<T> for Option<Infallible> {
+ type TryType = Option<T>;
+ }
// endregion:option
// region:result
// region:from
@@ -1037,10 +1054,14 @@ pub mod ops {
}
}
}
+
+ impl<T, E> const Residual<T> for Result<Infallible, E> {
+ type TryType = Result<T, E>;
+ }
// endregion:from
// endregion:result
}
- pub use self::try_::{ControlFlow, FromResidual, Try};
+ pub use self::try_::{ControlFlow, FromResidual, Residual, Try};
// endregion:try
// region:add