Skip to main content

MapRef

Trait MapRef 

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

Maps a successful result through a shared reference to its value.

The operation borrows the owned success value for the duration of the callback. An existing error is forwarded unchanged.

Required Methods§

Source

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

Applies op to a shared reference inside an Ok result.

The original success value is dropped after the callback returns. An Err result bypasses the callback and preserves its error.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

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