rune::alloc::prelude

Trait OptionExt

Source
pub trait OptionExt<T> {
    // Required method
    fn try_cloned(self) -> Result<Option<T>, Error>;
}
Expand description

Extensions to Option<T>.

Required Methods§

Source

fn try_cloned(self) -> Result<Option<T>, Error>

Maps an Option<&T> to an Option<T> by cloning the contents of the option.

§Examples
use rune::alloc::prelude::*;

let x = 12u32;
let opt_x = Some(&x);
assert_eq!(opt_x, Some(&12));
let cloned = opt_x.try_cloned()?;
assert_eq!(cloned, Some(12u32));

Implementations on Foreign Types§

Source§

impl<T> OptionExt<T> for Option<&T>
where T: TryClone,

Implementors§