pub trait OptionExt<'t, T: 't> { fn pipe(&'t self, f: F) -> Option where F: FnOnce(&'t T) -> U; } impl<'t, T: 't> OptionExt<'t, T> for Option { #[inline] fn pipe(&'t self, f: F) -> Option where F: FnOnce(&'t T) -> U, { match *self { Some(ref x) => Some(f(x)), None => None, } } }