diff options
| author | bors <bors@rust-lang.org> | 2015-07-14 11:13:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-07-14 11:13:21 +0000 |
| commit | e4e93196e16030ebf7a20c473849534235d676f8 (patch) | |
| tree | 80aea6062c36af59e6d8b59bd7609b313a6b5070 | |
| parent | 5708b1a18a39b3730f9a1af905b049f1b3600da7 (diff) | |
| parent | 7b51c1c5730feaacffbd094ed0ee732df29eafdf (diff) | |
| download | rust-e4e93196e16030ebf7a20c473849534235d676f8.tar.gz rust-e4e93196e16030ebf7a20c473849534235d676f8.zip | |
Auto merge of #27024 - bluss:io-drain, r=alexcrichton
Use Vec::drain in BufWriter I happened past a comment that asked for functionality that we now have.
| -rw-r--r-- | src/libstd/io/buffered.rs | 9 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 1 |
2 files changed, 2 insertions, 8 deletions
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 44541b78754..d6561ebb489 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -18,7 +18,6 @@ use cmp; use error; use fmt; use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom}; -use ptr; /// The `BufReader` struct adds buffering to any reader. /// @@ -308,14 +307,8 @@ impl<W: Write> BufWriter<W> { } } if written > 0 { - // NB: would be better expressed as .remove(0..n) if it existed - unsafe { - ptr::copy(self.buf.as_ptr().offset(written as isize), - self.buf.as_mut_ptr(), - len - written); - } + self.buf.drain(..written); } - self.buf.truncate(len - written); ret } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 1e82a03f286..53423cd5148 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -119,6 +119,7 @@ #![feature(core_intrinsics)] #![feature(core_prelude)] #![feature(core_simd)] +#![feature(drain)] #![feature(fnbox)] #![feature(heap_api)] #![feature(int_error_internals)] |
