Skip to main content

AndThenRef

Trait AndThenRef 

Source
pub trait AndThenRef<T, E> {
    // Required method
    fn and_then_ref<U, F>(self, op: F) -> Result<U, E>
       where F: FnOnce(&T) -> Result<U, E>;
}
Expand description

Chains a fallible operation over a shared reference to a success value.

The owned value is borrowed only while the callback runs. An existing error is forwarded without invoking the callback.

Required Methods§

Source

fn and_then_ref<U, F>(self, op: F) -> Result<U, E>
where F: FnOnce(&T) -> Result<U, E>,

Applies op to a shared reference inside an Ok result.

The callback may replace the success type or return the same error type. The original success value is dropped after the callback completes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, E> AndThenRef<T, E> for Result<T, E>