Trait fn_block::IntoSome [−][src]
This trait, which is implemented for all sized types,
provides the method into_some
, which moves the
value on which it is called into an Optional::Some
.
This is particularly useful when having to wrap a value into
a Some
at the end of a call chain.
Example:
let o : Option<String> = "foo bar ".trim().to_uppercase().into_some(); assert_eq!("FOO BAR", o.unwrap());
This can e.g. be used inside of
an expression wrapped in a fn_expr!
or fn_block!
macro.
Example using fn_expr!
:
let o = Some("Foobar"); let s = fn_expr!{ o?.get(0..3)?.to_lowercase().into_some() }; assert_eq!("foo", s.unwrap());
Required Methods
Implementors
impl<T> IntoSome for T