pub struct OptionResultBridge;Expand description
Utilities for converting between Option and Result in a typed fashion.
Implementations§
Source§impl OptionResultBridge
impl OptionResultBridge
Sourcepub fn to_result<T, E>(opt: Option<T>, err: E) -> Result<T, E>
pub fn to_result<T, E>(opt: Option<T>, err: E) -> Result<T, E>
Convert Option<T> to Result<T, E> with a supplied error.
Sourcepub fn to_result_with<T, E>(
opt: Option<T>,
f: impl FnOnce() -> E,
) -> Result<T, E>
pub fn to_result_with<T, E>( opt: Option<T>, f: impl FnOnce() -> E, ) -> Result<T, E>
Convert Option<T> to Result<T, E> with a lazy error.
Sourcepub fn from_result_ok<T, E>(r: Result<T, E>) -> Option<T>
pub fn from_result_ok<T, E>(r: Result<T, E>) -> Option<T>
Convert Result<T, E> to Option<T>, discarding the error.
Sourcepub fn from_result_err<T, E>(r: Result<T, E>) -> Option<E>
pub fn from_result_err<T, E>(r: Result<T, E>) -> Option<E>
Convert Result<T, E> to Option<E>, discarding the success.
Auto Trait Implementations§
impl Freeze for OptionResultBridge
impl RefUnwindSafe for OptionResultBridge
impl Send for OptionResultBridge
impl Sync for OptionResultBridge
impl Unpin for OptionResultBridge
impl UnsafeUnpin for OptionResultBridge
impl UnwindSafe for OptionResultBridge
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more