std::ops::Carrier

Trait std::ops::Carrier

pub trait Carrier {
    type Success;
    type Error;
    fn from_success(Self::Success) -> Self;
    fn from_error(Self::Error) -> Self;
    fn translate<T>(self) -> T    where        T: Carrier<Success = Self::Success, Error = Self::Error>;
}
???? This is a nightly-only experimental API. (question_mark_carrier #31436)

A trait for types which have success and error states and are meant to work with the question mark operator. When the ? operator is used with a value, whether the value is in the success or error state is determined by calling translate.

This trait is very experimental, it will probably be iterated on heavily before it is stabilised. Implementors should expect change. Users of ? should not rely on any implementations of Carrier other than Result, i.e., you should not expect ? to continue to work with Option, etc.

Associated Types

???? This is a nightly-only experimental API. (question_mark_carrier #31436)

The type of the value when computation succeeds.

???? This is a nightly-only experimental API. (question_mark_carrier #31436)

The type of the value when computation errors out.

Required Methods

???? This is a nightly-only experimental API. (question_mark_carrier #31436)

Create a Carrier from a success value.

???? This is a nightly-only experimental API. (question_mark_carrier #31436)

Create a Carrier from an error value.

???? This is a nightly-only experimental API. (question_mark_carrier #31436)

Translate this Carrier to another implementation of Carrier with the same associated types.

Implementors

  • impl<U, V> Carrier for Result<U, V>

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/ops/trait.Carrier.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部