Trait MapInto

Source
pub trait MapInto<T> {
    // Required method
    fn map_into(self) -> T;
}
Expand description

Maps a value using Into::into

Shorthand for Option::map(self, Into::into) and Result::map(self, Into::into)

use err_into::MapInto;

let value = Some(0u8);
let map_into: Option<i32> = value.map_into();
let map_into_std: Option<i32> = value.map(Into::into);
assert_eq!(map_into, map_into_std);

let result = Ok(0u8);
let map_into: Result<i32, ()> = result.map_into();
let map_into_std: Result<i32, ()> = result.map(Into::into);
assert_eq!(map_into, map_into_std);

Required Methods§

Source

fn map_into(self) -> T

Implementations on Foreign Types§

Source§

impl<T, U> MapInto<Option<U>> for Option<T>
where T: Into<U>,

Source§

fn map_into(self) -> Option<U>

Source§

impl<T, U, E> MapInto<Result<U, E>> for Result<T, E>
where T: Into<U>,

Source§

fn map_into(self) -> Result<U, E>

Implementors§