diff options
| author | bors <bors@rust-lang.org> | 2014-12-22 00:12:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-22 00:12:47 +0000 |
| commit | 34d680009205de2302b902d8f9f5f7ae7a042f1a (patch) | |
| tree | 2b7eb92a4d5a0d997871020964fe539390737dd3 /src/libstd/io | |
| parent | 1bdcfd64629930c09b942025e242e51e784c447d (diff) | |
| parent | fb7c08876e7b29c1b9d57df905f3ee0deec46aa1 (diff) | |
auto merge of #20104 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/comm_adapters.rs | 1 | ||||
| -rw-r--r-- | src/libstd/io/stdio.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/tempfile.rs | 50 |
3 files changed, 52 insertions, 1 deletions
diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/io/comm_adapters.rs index e865bf42bd0..3a18b0dc1b5 100644 --- a/src/libstd/io/comm_adapters.rs +++ b/src/libstd/io/comm_adapters.rs @@ -132,6 +132,7 @@ impl ChanWriter { } } +#[stable] impl Clone for ChanWriter { fn clone(&self) -> ChanWriter { ChanWriter { tx: self.tx.clone() } diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index aa50597c816..36dd5492356 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -104,7 +104,7 @@ pub struct StdinReader { inner: Arc<Mutex<BufferedReader<StdReader>>>, } -/// A guard for exlusive access to `StdinReader`'s internal `BufferedReader`. +/// A guard for exclusive access to `StdinReader`'s internal `BufferedReader`. pub struct StdinReaderGuard<'a> { inner: MutexGuard<'a, BufferedReader<StdReader>>, } diff --git a/src/libstd/io/tempfile.rs b/src/libstd/io/tempfile.rs index f3a11939995..c2b4d5a1fa9 100644 --- a/src/libstd/io/tempfile.rs +++ b/src/libstd/io/tempfile.rs @@ -23,6 +23,56 @@ use sync::atomic; /// A wrapper for a path to temporary directory implementing automatic /// scope-based deletion. +/// +/// # Examples +/// +/// ```no_run +/// use std::io::TempDir; +/// +/// { +/// // create a temporary directory +/// let tmpdir = match TempDir::new("mysuffix") { +/// Ok(dir) => dir, +/// Err(e) => panic!("couldn't create temporary directory: {}", e) +/// }; +/// +/// // get the path of the temporary directory without affecting the wrapper +/// let tmppath = tmpdir.path(); +/// +/// println!("The path of temporary directory is {}", tmppath.display()); +/// +/// // the temporary directory is automatically removed when tmpdir goes +/// // out of scope at the end of the block +/// } +/// { +/// // create a temporary directory, this time using a custom path +/// let tmpdir = match TempDir::new_in(&Path::new("/tmp/best/custom/path"), "mysuffix") { +/// Ok(dir) => dir, +/// Err(e) => panic!("couldn't create temporary directory: {}", e) +/// }; +/// +/// // get the path of the temporary directory and disable automatic deletion in the wrapper +/// let tmppath = tmpdir.into_inner(); +/// +/// println!("The path of the not-so-temporary directory is {}", tmppath.display()); +/// +/// // the temporary directory is not removed here +/// // because the directory is detached from the wrapper +/// } +/// { +/// // create a temporary directory +/// let tmpdir = match TempDir::new("mysuffix") { +/// Ok(dir) => dir, +/// Err(e) => panic!("couldn't create temporary directory: {}", e) +/// }; +/// +/// // close the temporary directory manually and check the result +/// match tmpdir.close() { +/// Ok(_) => println!("success!"), +/// Err(e) => panic!("couldn't remove temporary directory: {}", e) +/// }; +/// } +/// ``` pub struct TempDir { path: Option<Path>, disarmed: bool |
