summaryrefslogtreecommitdiffstats
path: root/tokio-fs/src/write.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tokio-fs/src/write.rs')
-rw-r--r--tokio-fs/src/write.rs29
1 files changed, 14 insertions, 15 deletions
diff --git a/tokio-fs/src/write.rs b/tokio-fs/src/write.rs
index 3f49cc01..b6f7511d 100644
--- a/tokio-fs/src/write.rs
+++ b/tokio-fs/src/write.rs
@@ -1,7 +1,7 @@
-use futures::{Async, Future, Poll};
+use crate::{file, File};
+use futures::{try_ready, Async, Future, Poll};
use std::{fmt, io, mem, path::Path};
use tokio_io;
-use {file, File};
/// Creates a future that will open a file for writing and write the entire
/// contents of `contents` to it.
@@ -11,20 +11,19 @@ use {file, File};
/// # Examples
///
/// ```no_run
-/// # extern crate tokio;
/// use tokio::prelude::Future;
-/// fn main() {
-/// let buffer = b"Hello world!";
-/// let task = tokio::fs::write("foo.txt", buffer).map(|data| {
-/// // `data` has now been written to foo.txt. The buffer is being
-/// // returned so it can be used for other things.
-/// println!("foo.txt now had {} bytes written to it", data.len());
-/// }).map_err(|e| {
-/// // handle errors
-/// eprintln!("IO error: {:?}", e);
-/// });
-/// tokio::run(task);
-/// }
+///
+/// let buffer = b"Hello world!";
+/// let task = tokio::fs::write("foo.txt", buffer).map(|data| {
+/// // `data` has now been written to foo.txt. The buffer is being
+/// // returned so it can be used for other things.
+/// println!("foo.txt now had {} bytes written to it", data.len());
+/// }).map_err(|e| {
+/// // handle errors
+/// eprintln!("IO error: {:?}", e);
+/// });
+///
+/// tokio::run(task);
/// ```
pub fn write<P, C: AsRef<[u8]>>(path: P, contents: C) -> WriteFile<P, C>
where