pub trait Filter { fn xfilter bool>(self, predicate: P) -> Self; } impl Filter for Option { fn xfilter bool>(self, predicate: P) -> Self { match self { Some(x) => { if predicate(&x) { Some(x) } else { None } } None => None, } } }