Skip to main content

tuwunel_core/utils/future/
mod.rs

1mod bool_ext;
2mod ext_ext;
3mod option_ext;
4mod option_stream;
5mod ready_bool_ext;
6mod ready_eq_ext;
7mod try_ext_ext;
8
9pub use self::{
10	bool_ext::{BoolExt, and, and4, and5, and6, and7, or},
11	ext_ext::ExtExt,
12	option_ext::OptionFutureExt,
13	option_stream::OptionStream,
14	ready_bool_ext::ReadyBoolExt,
15	ready_eq_ext::ReadyEqExt,
16	try_ext_ext::TryExtExt,
17};
18
19/// Unwrap the value from a `Poll<Option<T>>`, early-returning from the
20/// enclosing function on `Ready(None)` or `Pending`.
21///
22/// Must be invoked inside a function returning `Poll<Option<_>>`, such as a
23/// `Stream::poll_next` impl; the `return` arms otherwise produce a type
24/// mismatch at the enclosing function's return.
25#[macro_export]
26macro_rules! ready_some {
27	($e:expr) => {
28		match $e {
29			| std::task::Poll::Ready(Some(v)) => v,
30			| std::task::Poll::Ready(None) => return std::task::Poll::Ready(None),
31			| std::task::Poll::Pending => return std::task::Poll::Pending,
32		}
33	};
34}