mirror of https://github.com/rwf2/Rocket.git
Fix 'IntoOutcome' implementations for 'Option' and 'Result'.
Fixes #334.
This commit is contained in:
parent
85051eae49
commit
6df5564983
|
@ -23,7 +23,10 @@ impl<'a, S, E> IntoOutcome<S, (Status, E), Data> for Result<S, E> {
|
|||
|
||||
#[inline]
|
||||
fn or_forward(self, data: Data) -> Outcome<S, E> {
|
||||
Forward(data)
|
||||
match self {
|
||||
Ok(val) => Success(val),
|
||||
Err(_) => Forward(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,14 +125,20 @@ impl<S, E, F> IntoOutcome<S, E, F> for Option<S> {
|
|||
type Failure = E;
|
||||
type Forward = F;
|
||||
|
||||
#[inline(always)]
|
||||
fn into_outcome(self, val: E) -> Outcome<S, E, F> {
|
||||
Failure(val)
|
||||
#[inline]
|
||||
fn into_outcome(self, failure: E) -> Outcome<S, E, F> {
|
||||
match self {
|
||||
Some(val) => Success(val),
|
||||
None => Failure(failure)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn or_forward(self, val: F) -> Outcome<S, E, F> {
|
||||
Forward(val)
|
||||
#[inline]
|
||||
fn or_forward(self, forward: F) -> Outcome<S, E, F> {
|
||||
match self {
|
||||
Some(val) => Success(val),
|
||||
None => Forward(forward)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,10 @@ impl<S, E> IntoOutcome<S, (Status, E), ()> for Result<S, E> {
|
|||
|
||||
#[inline]
|
||||
fn or_forward(self, _: ()) -> Outcome<S, E> {
|
||||
Forward(())
|
||||
match self {
|
||||
Ok(val) => Success(val),
|
||||
Err(_) => Forward(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue