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.rs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/crates/test-utils/src/minicore.rs b/crates/test-utils/src/minicore.rs index 48c3e89525..7d95043867 100644 --- a/crates/test-utils/src/minicore.rs +++ b/crates/test-utils/src/minicore.rs @@ -43,6 +43,7 @@ //! dispatch_from_dyn: unsize, pin //! hash: sized //! include: +//! include_bytes: //! index: sized //! infallible: //! int_impl: size_of, transmute @@ -953,6 +954,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 +966,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 +995,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 +1022,10 @@ pub mod ops { } } } + + impl<T> const Residual<T> for Option<Infallible> { + type TryType = Option<T>; + } // endregion:option // region:result // region:from @@ -1037,10 +1055,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 @@ -2040,6 +2062,14 @@ mod macros { } // endregion:include + // region:include_bytes + #[rustc_builtin_macro] + #[macro_export] + macro_rules! include_bytes { + ($file:expr $(,)?) => {{ /* compiler built-in */ }}; + } + // endregion:include_bytes + // region:concat #[rustc_builtin_macro] #[macro_export] |