poa-bridge/bridge/src/macros.rs

18 lines
650 B
Rust
Raw Normal View History

2017-08-13 10:28:41 -07:00
macro_rules! try_bridge {
2017-08-12 11:03:48 -07:00
($e: expr) => (match $e {
Err(err) => return Err(From::from(err)),
2017-08-13 07:13:03 -07:00
Ok($crate::futures::Async::NotReady) => None,
Ok($crate::futures::Async::Ready(None)) => return Ok($crate::futures::Async::Ready(None)),
Ok($crate::futures::Async::Ready(Some(value))) => Some(value),
2017-08-12 11:03:48 -07:00
})
}
macro_rules! try_stream {
($e: expr) => (match $e {
Err(err) => return Err(From::from(err)),
2017-08-13 07:13:03 -07:00
Ok($crate::futures::Async::NotReady) => return Ok($crate::futures::Async::NotReady),
Ok($crate::futures::Async::Ready(None)) => return Ok($crate::futures::Async::Ready(None)),
Ok($crate::futures::Async::Ready(Some(value))) => value,
2017-08-12 11:03:48 -07:00
})
}