Add readme for web provider
Also rename sample web provider implemented in Rust to `web-rust`.
This commit is contained in:
18
providers/web/web-rust/src/utils.rs
Normal file
18
providers/web/web-rust/src/utils.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user