Merge pull request #272 from cramertj/must-use

Set Future types as must_use
This commit is contained in:
Alex Crichton
2017-10-27 12:19:21 -04:00
committed by GitHub
14 changed files with 18 additions and 0 deletions
+2
View File
@@ -23,6 +23,7 @@ use reactor::{Handle, PollEvented};
/// This type is created by the [`channel`] function.
///
/// [`channel`]: fn.channel.html
#[must_use = "sinks do nothing unless polled"]
pub struct Sender<T> {
tx: channel::Sender<T>,
}
@@ -37,6 +38,7 @@ pub struct Sender<T> {
/// `Stream` trait to represent received messages.
///
/// [`channel`]: fn.channel.html
#[must_use = "streams do nothing unless polled"]
pub struct Receiver<T> {
rx: PollEvented<channel::Receiver<T>>,
}
+1
View File
@@ -8,6 +8,7 @@ use futures::{Future, Poll};
/// bytes copied or an error if one happens.
///
/// [`copy`]: fn.copy.html
#[must_use = "futures do nothing unless polled"]
pub struct Copy<R, W> {
reader: R,
read_done: bool,
+1
View File
@@ -9,6 +9,7 @@ use futures::{Poll, Future, Async};
/// Created by the [`flush`] function.
///
/// [`flush`]: fn.flush.html
#[must_use = "futures do nothing unless polled"]
pub struct Flush<A> {
a: Option<A>,
}
+1
View File
@@ -310,6 +310,7 @@ pub trait Codec {
/// the `Codec` trait to encode and decode frames.
///
/// You can acquire a `Framed` instance by using the `Io::framed` adapter.
#[must_use = "streams do nothing unless polled"]
pub struct Framed<T, C> {
upstream: T,
codec: C,
+1
View File
@@ -26,6 +26,7 @@ pub fn read<R, T>(rd: R, buf: T) -> Read<R, T>
/// a buffer.
///
/// Created by the [`read`] function.
#[must_use = "futures do nothing unless polled"]
pub struct Read<R, T> {
state: State<R, T>,
}
+1
View File
@@ -9,6 +9,7 @@ use futures::{Poll, Future};
/// Created by the [`read_exact`] function.
///
/// [`read_exact`]: fn.read_exact.html
#[must_use = "futures do nothing unless polled"]
pub struct ReadExact<A, T> {
state: State<A, T>,
}
+1
View File
@@ -9,6 +9,7 @@ use futures::{Poll, Future};
/// Created by the [`read_to_end`] function.
///
/// [`read_to_end`]: fn.read_to_end.html
#[must_use = "futures do nothing unless polled"]
pub struct ReadToEnd<A> {
state: State<A>,
}
+1
View File
@@ -9,6 +9,7 @@ use futures::{Poll, Future};
/// Created by the [`read_until`] function.
///
/// [`read_until`]: fn.read_until.html
#[must_use = "futures do nothing unless polled"]
pub struct ReadUntil<A> {
state: State<A>,
}
+1
View File
@@ -8,6 +8,7 @@ use futures::{Poll, Future};
/// This is created by the [`write_all`] top-level method.
///
/// [`write_all`]: fn.write_all.html
#[must_use = "futures do nothing unless polled"]
pub struct WriteAll<A, T> {
state: State<A, T>,
}
+3
View File
@@ -25,6 +25,7 @@ pub struct TcpListener {
/// Stream returned by the `TcpListener::incoming` function representing the
/// stream of sockets received from a listener.
#[must_use = "streams do nothing unless polled"]
pub struct Incoming {
inner: TcpListener,
}
@@ -235,10 +236,12 @@ pub struct TcpStream {
/// Future returned by `TcpStream::connect` which will resolve to a `TcpStream`
/// when the stream is connected.
#[must_use = "futures do nothing unless polled"]
pub struct TcpStreamNew {
inner: TcpStreamNewState,
}
#[must_use = "futures do nothing unless polled"]
enum TcpStreamNewState {
Waiting(TcpStream),
Error(io::Error),
+1
View File
@@ -55,6 +55,7 @@ pub trait UdpCodec {
///
/// You can acquire a `UdpFramed` instance by using the `UdpSocket::framed`
/// adapter.
#[must_use = "sinks do nothing unless polled"]
pub struct UdpFramed<C> {
socket: UdpSocket,
codec: C,
+2
View File
@@ -394,6 +394,7 @@ impl fmt::Debug for UdpSocket {
/// A future used to write the entire contents of some data to a UDP socket.
///
/// This is created by the `UdpSocket::send_dgram` method.
#[must_use = "futures do nothing unless polled"]
pub struct SendDgram<T> {
state: SendState<T>,
}
@@ -441,6 +442,7 @@ impl<T> Future for SendDgram<T>
/// A future used to receive a datagram from a UDP socket.
///
/// This is created by the `UdpSocket::recv_dgram` method.
#[must_use = "futures do nothing unless polled"]
pub struct RecvDgram<T> {
state: RecvState<T>,
}
+1
View File
@@ -21,6 +21,7 @@ use reactor::timeout_token::TimeoutToken;
/// Note that timeouts are not intended for high resolution timers, but rather
/// they will likely fire some granularity after the exact instant that they're
/// otherwise indicated to fire at.
#[must_use = "streams do nothing unless polled"]
pub struct Interval {
token: TimeoutToken,
next: Instant,
+1
View File
@@ -18,6 +18,7 @@ use reactor::timeout_token::TimeoutToken;
/// Note that timeouts are not intended for high resolution timers, but rather
/// they will likely fire some granularity after the exact instant that they're
/// otherwise indicated to fire at.
#[must_use = "futures do nothing unless polled"]
#[derive(Debug)]
pub struct Timeout {
token: TimeoutToken,