Files
virtual-kubelet/providers/web/web-rust/src/utils.rs
Rajasekharan Vengalil 2abccb0257 Add readme for web provider
Also rename sample web provider implemented in Rust to `web-rust`.
2018-02-11 15:20:44 +05:30

19 lines
429 B
Rust

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