Add conversions between Sled results and Flow results
This commit is contained in:
parent
4114874156
commit
f9079db520
|
@ -141,6 +141,30 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<A, E: Error, FE: FatalError> From<std::result::Result<std::result::Result<A, E>, FE>>
|
||||||
|
for Result<A, E, FE>
|
||||||
|
{
|
||||||
|
fn from(res: std::result::Result<std::result::Result<A, E>, FE>) -> Self {
|
||||||
|
match res {
|
||||||
|
Ok(Ok(v)) => ok(v),
|
||||||
|
Ok(Err(e)) => error(e),
|
||||||
|
Err(e) => fatal(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<A, E: Error, FE: FatalError> From<Result<A, E, FE>>
|
||||||
|
for std::result::Result<std::result::Result<A, E>, FE>
|
||||||
|
{
|
||||||
|
fn from(res: Result<A, E, FE>) -> std::result::Result<std::result::Result<A, E>, FE> {
|
||||||
|
match res {
|
||||||
|
Result::Ok(v) => Ok(Ok(v)),
|
||||||
|
Result::Err(e) => Ok(Err(e)),
|
||||||
|
Result::Fatal(e) => Err(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Convenience function to create an ok value.
|
/// Convenience function to create an ok value.
|
||||||
pub fn ok<A, E: Error, FE: FatalError>(val: A) -> Result<A, E, FE> {
|
pub fn ok<A, E: Error, FE: FatalError>(val: A) -> Result<A, E, FE> {
|
||||||
Result::Ok(val)
|
Result::Ok(val)
|
||||||
|
|
Loading…
Reference in New Issue