add must_use for Future (#450)

This commit is contained in:
Guanqun Lu
2018-09-04 18:30:57 +08:00
committed by Toralf Wittner
parent 02576eecf1
commit ee9be6f0c9
11 changed files with 14 additions and 0 deletions

View File

@ -562,6 +562,7 @@ where
}
/// Implementation of `Future` that yields the next incoming substream from a dialed connection.
#[must_use = "futures do nothing unless polled"]
pub struct ConnectionReuseIncoming<T, D, M>
where
T: Transport,

View File

@ -213,6 +213,7 @@ where
}
#[derive(Debug, Copy, Clone)]
#[must_use = "futures do nothing unless polled"]
pub enum EitherOutbound<A: StreamMuxer, B: StreamMuxer> {
A(A::OutboundSubstream),
B(B::OutboundSubstream),
@ -220,6 +221,7 @@ pub enum EitherOutbound<A: StreamMuxer, B: StreamMuxer> {
/// Implements `Stream` and dispatches all method calls to either `First` or `Second`.
#[derive(Debug, Copy, Clone)]
#[must_use = "futures do nothing unless polled"]
pub enum EitherListenStream<A, B> {
First(A),
Second(B),
@ -248,6 +250,7 @@ where
// If Rust had impl Trait we could use the Either enum from the futures crate and add some
// modifiers to it. This custom enum is a combination of Either and these modifiers.
#[derive(Debug, Copy, Clone)]
#[must_use = "futures do nothing unless polled"]
pub enum EitherListenUpgrade<A, B> {
First(A),
Second(B),

View File

@ -222,6 +222,7 @@ where
}
/// Future that must be driven to completion in order for the swarm to work.
#[must_use = "futures do nothing unless polled"]
pub struct SwarmFuture<T, H>
where
T: MuxedTransport + 'static, // TODO: 'static :-/

View File

@ -96,6 +96,7 @@ pub struct Interrupt {
_tx: oneshot::Sender<()>,
}
#[must_use = "futures do nothing unless polled"]
pub struct InterruptibleDial<F> {
inner: F,
rx: future::Shared<oneshot::Receiver<()>>,

View File

@ -342,6 +342,7 @@ impl<T> Drop for UniqueConnec<T> {
}
/// Future returned by `UniqueConnec::dial()`.
#[must_use = "futures do nothing unless polled"]
pub struct UniqueConnecFuture<T> {
inner: Weak<Mutex<UniqueConnecInner<T>>>,
}

View File

@ -92,6 +92,7 @@ pub enum EitherUpgradeIdentifier<A, B> {
// If Rust had impl Trait we could use the Either enum from the futures crate and add some
// modifiers to it. This custom enum is a combination of Either and these modifiers.
#[derive(Debug, Copy, Clone)]
#[must_use = "futures do nothing unless polled"]
pub enum EitherConnUpgrFuture<A, B> {
First(A),
Second(B),