mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
add #[must_use] to more futures and streams (#1309)
This commit is contained in:
@@ -17,6 +17,7 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> CreateDirFuture<P> {
|
||||
|
||||
/// Future returned by `create_dir`.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct CreateDirFuture<P>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
|
||||
@@ -18,6 +18,7 @@ pub fn create_dir_all<P: AsRef<Path>>(path: P) -> CreateDirAllFuture<P> {
|
||||
|
||||
/// Future returned by `create_dir_all`.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct CreateDirAllFuture<P>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
|
||||
@@ -13,6 +13,7 @@ use std::task::Poll;
|
||||
///
|
||||
/// Will panic if polled after returning an item or error.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct CloneFuture {
|
||||
file: Option<File>,
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use std::task::Context;
|
||||
use std::task::Poll;
|
||||
|
||||
/// Future returned by `File::create` and resolves to a `File` instance.
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
#[derive(Debug)]
|
||||
pub struct CreateFuture<P> {
|
||||
path: P,
|
||||
|
||||
@@ -11,6 +11,7 @@ const POLL_AFTER_RESOLVE: &str = "Cannot poll MetadataFuture after it resolves";
|
||||
|
||||
/// Future returned by `File::metadata` and resolves to a `(File, Metadata)` instance.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct MetadataFuture {
|
||||
file: Option<File>,
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use std::task::Poll;
|
||||
|
||||
/// Future returned by `File::open` and resolves to a `File` instance.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct OpenFuture<P: Unpin> {
|
||||
options: StdOpenOptions,
|
||||
path: P,
|
||||
|
||||
@@ -7,6 +7,7 @@ use std::task::Poll;
|
||||
|
||||
/// Future returned by `File::seek`.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct SeekFuture {
|
||||
inner: Option<File>,
|
||||
pos: io::SeekFrom,
|
||||
|
||||
@@ -20,6 +20,7 @@ pub fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> HardLinkFutu
|
||||
|
||||
/// Future returned by `hard_link`.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct HardLinkFuture<P, Q>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
|
||||
@@ -17,6 +17,7 @@ where
|
||||
|
||||
/// Future returned by `metadata`.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct MetadataFuture<P>
|
||||
where
|
||||
P: AsRef<Path> + Send + 'static,
|
||||
|
||||
@@ -38,6 +38,7 @@ where
|
||||
|
||||
/// A future used to open a file and read its entire contents into a buffer.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct ReadFile<P: AsRef<Path> + Send + Unpin + 'static> {
|
||||
state: State<P>,
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ where
|
||||
|
||||
/// Future returned by `read_dir`.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct ReadDirFuture<P>
|
||||
where
|
||||
P: AsRef<Path> + Send + 'static,
|
||||
@@ -68,6 +69,7 @@ where
|
||||
/// [`Stream`]: ../futures/stream/trait.Stream.html
|
||||
/// [`Err`]: https://doc.rust-lang.org/std/result/enum.Result.html#variant.Err
|
||||
#[derive(Debug)]
|
||||
#[must_use = "streams do nothing unless polled"]
|
||||
pub struct ReadDir(StdReadDir);
|
||||
|
||||
impl Stream for ReadDir {
|
||||
|
||||
@@ -17,6 +17,7 @@ pub fn read_link<P: AsRef<Path>>(path: P) -> ReadLinkFuture<P> {
|
||||
|
||||
/// Future returned by `read_link`.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct ReadLinkFuture<P>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
|
||||
@@ -17,6 +17,7 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> RemoveDirFuture<P> {
|
||||
|
||||
/// Future returned by `remove_dir`.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct RemoveDirFuture<P>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
|
||||
@@ -21,6 +21,7 @@ pub fn remove_file<P: AsRef<Path>>(path: P) -> RemoveFileFuture<P> {
|
||||
|
||||
/// Future returned by `remove_file`.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct RemoveFileFuture<P>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
|
||||
@@ -20,6 +20,7 @@ pub fn rename<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> RenameFuture<P,
|
||||
|
||||
/// Future returned by `rename`.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct RenameFuture<P, Q>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
|
||||
@@ -17,6 +17,7 @@ pub fn set_permissions<P: AsRef<Path>>(path: P, perm: fs::Permissions) -> SetPer
|
||||
|
||||
/// Future returned by `set_permissions`.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct SetPermissionsFuture<P>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
|
||||
@@ -21,6 +21,7 @@ where
|
||||
|
||||
/// Future returned by `symlink_metadata`.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct SymlinkMetadataFuture<P>
|
||||
where
|
||||
P: AsRef<Path> + Send + 'static,
|
||||
|
||||
@@ -41,6 +41,7 @@ where
|
||||
/// A future used to open a file for writing and write the entire contents
|
||||
/// of some data to it.
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct WriteFile<P: AsRef<Path> + Send + Unpin + 'static, C: AsRef<[u8]> + Unpin> {
|
||||
state: State<P, C>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user