Trait MapInto

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

Helper trait to map a container of T to a container of some type F that implements From.

For example, Result to Result<From>, or Option to Option<From>.

Required Methods§

Source

fn map_into(self) -> T

Map the contained T into a different type.

Essentially, .map_into() is the same as doing .map(|val| val.into()).

Example

use genie_support::MapInto;

let a: Option<u8> = Some(10);
let b: Option<u16> = a.map_into();
assert_eq!(b, Some(10u16));

Implementations on Foreign Types§

Source§

impl<Source, Target> MapInto<Option<Target>> for Option<Source>
where Target: From<Source>,

Source§

fn map_into(self) -> Option<Target>

Source§

impl<Source, Target, Error> MapInto<Result<Target, Error>> for Result<Source, Error>
where Target: From<Source>,

Source§

fn map_into(self) -> Result<Target, Error>

Implementors§