finchers_ext/option/
mod.rs1mod map_some;
4mod ok_or_else;
5
6pub use self::map_some::MapSome;
7pub use self::ok_or_else::OkOrElse;
8
9use finchers_core::Endpoint;
10use finchers_core::endpoint::assert_output;
11
12pub trait EndpointOptionExt<T>: Endpoint<Output = Option<T>> + Sized {
14 fn map_some<F, U>(self, f: F) -> MapSome<Self, F>
16 where
17 F: FnOnce(T) -> U + Clone + Send + Sync,
18 {
19 assert_output::<_, Option<U>>(self::map_some::new(self, f))
20 }
21
22 fn ok_or_else<F, U>(self, f: F) -> OkOrElse<Self, F>
24 where
25 F: FnOnce() -> U + Clone + Send + Sync,
26 {
27 assert_output::<_, Result<T, U>>(self::ok_or_else::new(self, f))
28 }
29}
30
31impl<E, T> EndpointOptionExt<T> for E
32where
33 E: Endpoint<Output = Option<T>>,
34{
35}