#[doc(inline)]
pub use crate::__res_unwrap_or as unwrap_or;
#[doc(hidden)]
#[macro_export]
macro_rules! __res_unwrap_or {
($res:expr, $v:expr $(,)?) => {
match $crate::__ResT!($res, $v) {
$crate::__PResT!($crate::__::Ok(x), _) => x,
$crate::__PResT!($crate::__::Err(_), value) => value,
}
};
}
#[doc = crate::docs::closure_arg_pattern_limitations_docs!("")]
#[doc(inline)]
pub use crate::__res_unwrap_or_else as unwrap_or_else;
#[doc(hidden)]
#[macro_export]
macro_rules! __res_unwrap_or_else {
($res:expr, |$param:pat_param| $expr:expr $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok(x) => x,
$crate::__::Err($param) => $expr,
}
};
($res:expr, | $($anything:tt)* ) => {
compile_error!("expected the closure to take a pattern as an argument")
};
($res:expr, || $($anything:tt)* ) => {
compile_error!("expected the closure to take a pattern as an argument")
};
($res:expr, $function:path $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok(x) => x,
$crate::__::Err(x) => $function(x),
}
};
}
#[doc = crate::docs::closure_arg_pattern_limitations_docs!("")]
#[doc(inline)]
pub use crate::__res_unwrap_err_or_else as unwrap_err_or_else;
#[doc(hidden)]
#[macro_export]
macro_rules! __res_unwrap_err_or_else {
($res:expr, |$param:pat_param| $expr:expr $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok($param) => $expr,
$crate::__::Err(x) => x,
}
};
($res:expr, | $($anything:tt)* ) => {
compile_error!("expected the closure to take a pattern as an argument")
};
($res:expr, || $($anything:tt)* ) => {
compile_error!("expected the closure to take a pattern as an argument")
};
($res:expr, $function:path $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok(x) => $function(x),
$crate::__::Err(x) => x,
}
};
}
#[doc(inline)]
pub use crate::__res_ok as ok;
#[doc(hidden)]
#[macro_export]
macro_rules! __res_ok {
($res:expr $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok(x) => $crate::__::Some(x),
$crate::__::Err(_) => $crate::__::None,
}
};
}
#[doc(inline)]
pub use crate::__res_err as err;
#[doc(hidden)]
#[macro_export]
macro_rules! __res_err {
($res:expr $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok(_) => $crate::__::None,
$crate::__::Err(x) => $crate::__::Some(x),
}
};
}
#[doc = crate::docs::closure_arg_pattern_limitations_docs!("")]
#[doc(inline)]
pub use crate::__res_map as map;
#[doc(hidden)]
#[macro_export]
macro_rules! __res_map {
($res:expr, |$param:pat_param| $expr:expr $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok($param) => $crate::__::Ok($expr),
$crate::__::Err(x) => $crate::__::Err(x),
}
};
($res:expr, | $($anything:tt)* ) => {
compile_error!("expected the closure to take a pattern as an argument")
};
($res:expr, || $($anything:tt)* ) => {
compile_error!("expected the closure to take a pattern as an argument")
};
($res:expr, $function:path $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok(param) => $crate::__::Ok($function(param)),
$crate::__::Err(x) => $crate::__::Err(x),
}
};
}
#[doc = crate::docs::closure_arg_pattern_limitations_docs!("")]
#[doc(inline)]
pub use crate::__res_map_err as map_err;
#[doc(hidden)]
#[macro_export]
macro_rules! __res_map_err {
($res:expr, |$param:pat_param| $expr:expr $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok(x) => $crate::__::Ok(x),
$crate::__::Err($param) => $crate::__::Err($expr),
}
};
($res:expr, | $($anything:tt)* ) => {
compile_error!("expected the closure to take a pattern as an argument")
};
($res:expr, || $($anything:tt)* ) => {
compile_error!("expected the closure to take a pattern as an argument")
};
($res:expr, $function:path $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok(x) => $crate::__::Ok(x),
$crate::__::Err(x) => $crate::__::Err($function(x)),
}
};
}
#[doc = crate::docs::closure_arg_pattern_limitations_docs!("")]
#[doc(inline)]
pub use crate::__res_and_then as and_then;
#[doc(hidden)]
#[macro_export]
macro_rules! __res_and_then {
($res:expr, |$param:pat_param| $expr:expr $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok($param) => $expr,
$crate::__::Err(x) => $crate::__::Err(x),
}
};
($res:expr, | $($anything:tt)* ) => {
compile_error!("expected the closure to take a pattern as an argument")
};
($res:expr, || $($anything:tt)* ) => {
compile_error!("expected the closure to take a pattern as an argument")
};
($res:expr, $function:path $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok(param) => $function(param),
$crate::__::Err(x) => $crate::__::Err(x),
}
};
}
#[doc = crate::docs::closure_arg_pattern_limitations_docs!("")]
#[doc(inline)]
pub use crate::__res_or_else as or_else;
#[doc(hidden)]
#[macro_export]
macro_rules! __res_or_else {
($res:expr, |$param:pat_param| $expr:expr $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok(x) => $crate::__::Ok(x),
$crate::__::Err($param) => $expr,
}
};
($res:expr, | $($anything:tt)* ) => {
compile_error!("expected the closure to take a pattern as an argument")
};
($res:expr, || $($anything:tt)* ) => {
compile_error!("expected the closure to take a pattern as an argument")
};
($res:expr, $function:path $(,)?) => {
match $crate::__Res!($res).res {
$crate::__::Ok(x) => $crate::__::Ok(x),
$crate::__::Err(x) => $function(x),
}
};
}
#[doc(no_inline)]
pub use const_panic::{unwrap_err, unwrap_ok as unwrap};
#[doc(hidden)]
pub struct __Res<T, E> {
pub res: Result<T, E>,
}
#[doc(hidden)]
#[macro_export]
macro_rules! __Res {
($($res:tt)*) => { $crate::result::__Res { res: $($res)* } };
}
#[doc(hidden)]
pub struct __ResT<T, E> {
pub res: Result<T, E>,
pub val: T,
}
#[doc(hidden)]
#[macro_export]
macro_rules! __ResT {
($res:tt, $val:tt) => {
$crate::result::__ResT {
res: $res,
val: $val,
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __PResT {
($res:pat, $val:pat) => {
$crate::result::__ResT {
res: $res,
val: $val,
}
};
}