mirror of https://github.com/rwf2/Rocket.git
Document 'IntoOutcome'.
This commit is contained in:
parent
00df2846d7
commit
a94dc9a270
|
@ -104,10 +104,20 @@ pub enum Outcome<S, E, F> {
|
||||||
|
|
||||||
/// Conversion trait from some type into an Outcome type.
|
/// Conversion trait from some type into an Outcome type.
|
||||||
pub trait IntoOutcome<S, E, F> {
|
pub trait IntoOutcome<S, E, F> {
|
||||||
|
/// The type to use when returning an `Outcome::Failure`.
|
||||||
type Failure: Sized;
|
type Failure: Sized;
|
||||||
|
|
||||||
|
/// The type to use when returning an `Outcome::Forward`.
|
||||||
type Forward: Sized;
|
type Forward: Sized;
|
||||||
|
|
||||||
|
/// Converts `self` into an `Outcome`. If `self` represents a success, an
|
||||||
|
/// `Outcome::Success` is returned. Otherwise, an `Outcome::Failure` is
|
||||||
|
/// returned with `failure` as the inner value.
|
||||||
fn into_outcome(self, failure: Self::Failure) -> Outcome<S, E, F>;
|
fn into_outcome(self, failure: Self::Failure) -> Outcome<S, E, F>;
|
||||||
|
|
||||||
|
/// Converts `self` into an `Outcome`. If `self` represents a success, an
|
||||||
|
/// `Outcome::Success` is returned. Otherwise, an `Outcome::Forward` is
|
||||||
|
/// returned with `forward` as the inner value.
|
||||||
fn or_forward(self, forward: Self::Forward) -> Outcome<S, E, F>;
|
fn or_forward(self, forward: Self::Forward) -> Outcome<S, E, F>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,10 +125,12 @@ impl<S, E, F> IntoOutcome<S, E, F> for Option<S> {
|
||||||
type Failure = E;
|
type Failure = E;
|
||||||
type Forward = F;
|
type Forward = F;
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn into_outcome(self, val: E) -> Outcome<S, E, F> {
|
fn into_outcome(self, val: E) -> Outcome<S, E, F> {
|
||||||
Failure(val)
|
Failure(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
fn or_forward(self, val: F) -> Outcome<S, E, F> {
|
fn or_forward(self, val: F) -> Outcome<S, E, F> {
|
||||||
Forward(val)
|
Forward(val)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue