about summary refs log tree commit diff
path: root/src/libstd/io
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-09-22 05:30:30 +0000
committerbors <bors@rust-lang.org>2014-09-22 05:30:30 +0000
commitcbb07e81be99271f9e240a27dcf540686d8c0bfc (patch)
treea0a2ce0e5d9e65137f445201cbcd01324ca0d275 /src/libstd/io
parent4e5b62618cb5341139177c1ef62e2467affd041f (diff)
parent0169218047dc989acf9ea25e3122b9c659acb6b3 (diff)
downloadrust-cbb07e81be99271f9e240a27dcf540686d8c0bfc.tar.gz
rust-cbb07e81be99271f9e240a27dcf540686d8c0bfc.zip
auto merge of #17029 : alexcrichton/rust/vec-stable, r=aturon
The following methods, types, and names have become stable:

* Vec
* Vec::as_mut_slice
* Vec::as_slice
* Vec::capacity
* Vec::clear
* Vec::default
* Vec::grow
* Vec::insert
* Vec::len
* Vec::new
* Vec::pop
* Vec::push
* Vec::remove
* Vec::set_len
* Vec::shrink_to_fit
* Vec::truncate
* Vec::with_capacity
* vec::raw
* vec::raw::from_buf
* vec::raw::from_raw_parts

The following have become unstable:

* Vec::dedup        // naming
* Vec::from_fn      // naming and unboxed closures
* Vec::get_mut      // will be removed for IndexMut
* Vec::grow_fn      // unboxed closures and naming
* Vec::retain       // unboxed closures
* Vec::swap_remove  // uncertain naming
* Vec::from_elem    // uncertain semantics
* vec::unzip        // should be generic for all collections

The following have been deprecated

* Vec::append - call .extend()
* Vec::append_one - call .push()
* Vec::from_slice - call .to_vec()
* Vec::grow_set - call .grow() and then .push()
* Vec::into_vec - move the vector instead
* Vec::move_iter - renamed to iter_move()
* Vec::push_all - call .extend()
* Vec::to_vec - call .clone()
* Vec:from_raw_parts - moved to raw::from_raw_parts

This is a breaking change in terms of the signature of the `Vec::grow` function.
The argument used to be taken by reference, but it is now taken by value. Code
must update by removing a leading `&` sigil or by calling `.clone()` to create a
value.

[breaking-change]
Diffstat (limited to 'src/libstd/io')
-rw-r--r--src/libstd/io/buffered.rs10
-rw-r--r--src/libstd/io/comm_adapters.rs4
-rw-r--r--src/libstd/io/extensions.rs24
-rw-r--r--src/libstd/io/fs.rs4
-rw-r--r--src/libstd/io/net/ip.rs16
-rw-r--r--src/libstd/io/tempfile.rs2
6 files changed, 33 insertions, 27 deletions
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs
index a777a372ad1..d9543a06b35 100644
--- a/src/libstd/io/buffered.rs
+++ b/src/libstd/io/buffered.rs
@@ -162,7 +162,7 @@ impl<W: Writer> BufferedWriter<W> {
 
     fn flush_buf(&mut self) -> IoResult<()> {
         if self.pos != 0 {
-            let ret = self.inner.get_mut_ref().write(self.buf.slice_to(self.pos));
+            let ret = self.inner.as_mut().unwrap().write(self.buf.slice_to(self.pos));
             self.pos = 0;
             ret
         } else {
@@ -174,7 +174,7 @@ impl<W: Writer> BufferedWriter<W> {
     ///
     /// This type does not expose the ability to get a mutable reference to the
     /// underlying reader because that could possibly corrupt the buffer.
-    pub fn get_ref<'a>(&'a self) -> &'a W { self.inner.get_ref() }
+    pub fn get_ref<'a>(&'a self) -> &'a W { self.inner.as_ref().unwrap() }
 
     /// Unwraps this `BufferedWriter`, returning the underlying writer.
     ///
@@ -193,7 +193,7 @@ impl<W: Writer> Writer for BufferedWriter<W> {
         }
 
         if buf.len() > self.buf.len() {
-            self.inner.get_mut_ref().write(buf)
+            self.inner.as_mut().unwrap().write(buf)
         } else {
             let dst = self.buf.slice_from_mut(self.pos);
             slice::bytes::copy_memory(dst, buf);
@@ -203,7 +203,7 @@ impl<W: Writer> Writer for BufferedWriter<W> {
     }
 
     fn flush(&mut self) -> IoResult<()> {
-        self.flush_buf().and_then(|()| self.inner.get_mut_ref().flush())
+        self.flush_buf().and_then(|()| self.inner.as_mut().unwrap().flush())
     }
 }
 
@@ -273,7 +273,7 @@ impl<W> InternalBufferedWriter<W> {
 
 impl<W: Reader> Reader for InternalBufferedWriter<W> {
     fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
-        self.get_mut().inner.get_mut_ref().read(buf)
+        self.get_mut().inner.as_mut().unwrap().read(buf)
     }
 }
 
diff --git a/src/libstd/io/comm_adapters.rs b/src/libstd/io/comm_adapters.rs
index f2ff5c7b5c2..0a969fc37c9 100644
--- a/src/libstd/io/comm_adapters.rs
+++ b/src/libstd/io/comm_adapters.rs
@@ -15,7 +15,7 @@ use comm::{Sender, Receiver};
 use io;
 use option::{None, Option, Some};
 use result::{Ok, Err};
-use slice::{bytes, MutableSlice, ImmutableSlice};
+use slice::{bytes, MutableSlice, ImmutableSlice, CloneableVector};
 use str::StrSlice;
 use super::{Reader, Writer, IoResult};
 use vec::Vec;
@@ -118,7 +118,7 @@ impl Clone for ChanWriter {
 
 impl Writer for ChanWriter {
     fn write(&mut self, buf: &[u8]) -> IoResult<()> {
-        self.tx.send_opt(Vec::from_slice(buf)).map_err(|_| {
+        self.tx.send_opt(buf.to_vec()).map_err(|_| {
             io::IoError {
                 kind: io::BrokenPipe,
                 desc: "Pipe closed",
diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs
index b61e7c6b441..a93f9826fa5 100644
--- a/src/libstd/io/extensions.rs
+++ b/src/libstd/io/extensions.rs
@@ -16,13 +16,14 @@
 // FIXME: Iteration should probably be considered separately
 
 use collections::{Collection, MutableSeq};
+use io::{IoError, IoResult, Reader};
+use io;
 use iter::Iterator;
+use num::Int;
 use option::{Option, Some, None};
+use ptr::RawPtr;
 use result::{Ok, Err};
-use io;
-use io::{IoError, IoResult, Reader};
 use slice::{ImmutableSlice, Slice};
-use ptr::RawPtr;
 
 /// An iterator that reads a single byte on each iteration,
 /// until `.read_byte()` returns `EndOfFile`.
@@ -76,16 +77,15 @@ impl<'r, R: Reader> Iterator<IoResult<u8>> for Bytes<'r, R> {
 ///
 /// This function returns the value returned by the callback, for convenience.
 pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
-    use mem::{to_le16, to_le32, to_le64};
     use mem::transmute;
 
     // LLVM fails to properly optimize this when using shifts instead of the to_le* intrinsics
     assert!(size <= 8u);
     match size {
       1u => f(&[n as u8]),
-      2u => f(unsafe { transmute::<_, [u8, ..2]>(to_le16(n as u16)) }),
-      4u => f(unsafe { transmute::<_, [u8, ..4]>(to_le32(n as u32)) }),
-      8u => f(unsafe { transmute::<_, [u8, ..8]>(to_le64(n)) }),
+      2u => f(unsafe { transmute::<_, [u8, ..2]>((n as u16).to_le()) }),
+      4u => f(unsafe { transmute::<_, [u8, ..4]>((n as u32).to_le()) }),
+      8u => f(unsafe { transmute::<_, [u8, ..8]>(n.to_le()) }),
       _ => {
 
         let mut bytes = vec!();
@@ -116,16 +116,15 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
 ///
 /// This function returns the value returned by the callback, for convenience.
 pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
-    use mem::{to_be16, to_be32, to_be64};
     use mem::transmute;
 
     // LLVM fails to properly optimize this when using shifts instead of the to_be* intrinsics
     assert!(size <= 8u);
     match size {
       1u => f(&[n as u8]),
-      2u => f(unsafe { transmute::<_, [u8, ..2]>(to_be16(n as u16)) }),
-      4u => f(unsafe { transmute::<_, [u8, ..4]>(to_be32(n as u32)) }),
-      8u => f(unsafe { transmute::<_, [u8, ..8]>(to_be64(n)) }),
+      2u => f(unsafe { transmute::<_, [u8, ..2]>((n as u16).to_be()) }),
+      4u => f(unsafe { transmute::<_, [u8, ..4]>((n as u32).to_be()) }),
+      8u => f(unsafe { transmute::<_, [u8, ..8]>(n.to_be()) }),
       _ => {
         let mut bytes = vec!();
         let mut i = size;
@@ -152,7 +151,6 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
 ///           32-bit value is parsed.
 pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
     use ptr::{copy_nonoverlapping_memory};
-    use mem::from_be64;
     use slice::MutableSlice;
 
     assert!(size <= 8u);
@@ -166,7 +164,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
         let ptr = data.as_ptr().offset(start as int);
         let out = buf.as_mut_ptr();
         copy_nonoverlapping_memory(out.offset((8 - size) as int), ptr, size);
-        from_be64(*(out as *const u64))
+        (*(out as *const u64)).to_be()
     }
 }
 
diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs
index f912b3ee38f..b8e18fc44cb 100644
--- a/src/libstd/io/fs.rs
+++ b/src/libstd/io/fs.rs
@@ -61,7 +61,7 @@ use io::{IoResult, IoError, FileStat, SeekStyle, Seek, Writer, Reader};
 use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append};
 use io::UpdateIoError;
 use io;
-use iter::Iterator;
+use iter::{Iterator, Extendable};
 use kinds::Send;
 use libc;
 use option::{Some, None, Option};
@@ -688,7 +688,7 @@ impl Iterator<Path> for Directories {
                                                 e, path.display()));
 
                     match result {
-                        Ok(dirs) => { self.stack.push_all_move(dirs); }
+                        Ok(dirs) => { self.stack.extend(dirs.into_iter()); }
                         Err(..) => {}
                     }
                 }
diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs
index 1141cd22eeb..6eb7d1c02fb 100644
--- a/src/libstd/io/net/ip.rs
+++ b/src/libstd/io/net/ip.rs
@@ -103,7 +103,12 @@ impl<'a> Parser<'a> {
     // Commit only if parser read till EOF
     fn read_till_eof<T>(&mut self, cb: |&mut Parser| -> Option<T>)
                      -> Option<T> {
-        self.read_atomically(|p| cb(p).filtered(|_| p.is_eof()))
+        self.read_atomically(|p| {
+            match cb(p) {
+                Some(x) => if p.is_eof() {Some(x)} else {None},
+                None => None,
+            }
+        })
     }
 
     // Return result of first successful parser
@@ -152,7 +157,10 @@ impl<'a> Parser<'a> {
     // Return char and advance iff next char is equal to requested
     fn read_given_char(&mut self, c: char) -> Option<char> {
         self.read_atomically(|p| {
-            p.read_char().filtered(|&next| next == c)
+            match p.read_char() {
+                Some(next) if next == c => Some(next),
+                _ => None,
+            }
         })
     }
 
@@ -232,8 +240,8 @@ impl<'a> Parser<'a> {
         fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr {
             assert!(head.len() + tail.len() <= 8);
             let mut gs = [0u16, ..8];
-            gs.copy_from(head);
-            gs.slice_mut(8 - tail.len(), 8).copy_from(tail);
+            gs.clone_from_slice(head);
+            gs.slice_mut(8 - tail.len(), 8).clone_from_slice(tail);
             Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
         }
 
diff --git a/src/libstd/io/tempfile.rs b/src/libstd/io/tempfile.rs
index 6c9f10e19ae..9d6713b25b7 100644
--- a/src/libstd/io/tempfile.rs
+++ b/src/libstd/io/tempfile.rs
@@ -79,7 +79,7 @@ impl TempDir {
 
     /// Access the wrapped `std::path::Path` to the temporary directory.
     pub fn path<'a>(&'a self) -> &'a Path {
-        self.path.get_ref()
+        self.path.as_ref().unwrap()
     }
 
     /// Close and remove the temporary directory