pub trait Residual<O> {
type TryType: Try<Output = O, Residual = Self>;
}🔬This is a nightly-only experimental API. (
try_trait_v2_residual #91285)Expand description
允许检索实现 Try 的规范类型,该类型具有此类型作为它的残差,并允许它保留 O 作为它的输出。
如果您将 Try trait 视为将类型拆分为其 Try::Output 和 Try::Residual 组件,则可以将它们重新组合在一起。
例如,Result<T, E>: Try<Output = T, Residual = Result<Infallible, E>>,在另一个方向上,<Result<Infallible, E> as Residual<T>>::TryType = Result<T, E>。