Introduce OptionFuture helpers
Optimize user directory searches
This commit is contained in:
11
src/core/utils/option.rs
Normal file
11
src/core/utils/option.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use futures::future::OptionFuture;
|
||||
|
||||
pub trait OptionExt<T> {
|
||||
fn map_async<O: Future, F: FnOnce(T) -> O>(self, f: F) -> OptionFuture<O>;
|
||||
}
|
||||
|
||||
impl<T> OptionExt<T> for Option<T> {
|
||||
fn map_async<O: Future, F: FnOnce(T) -> O>(self, f: F) -> OptionFuture<O> {
|
||||
OptionFuture::<_>::from(self.map(f))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user