diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-09-17 10:47:05 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-09-21 21:05:05 -0700 |
| commit | 81d1feb9804f66034df4f218cc8fb0209c7450a7 (patch) | |
| tree | 0c524deb8ce5015102af2d2f7a0df93d0fd2f5f7 /src/libstd/io | |
| parent | 72841b128df8b6a4eb88b1048548e2eec5244449 (diff) | |
| download | rust-81d1feb9804f66034df4f218cc8fb0209c7450a7.tar.gz rust-81d1feb9804f66034df4f218cc8fb0209c7450a7.zip | |
Remove #[allow(deprecated)] from libstd
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/buffered.rs | 10 | ||||
| -rw-r--r-- | src/libstd/io/extensions.rs | 24 | ||||
| -rw-r--r-- | src/libstd/io/net/ip.rs | 16 | ||||
| -rw-r--r-- | src/libstd/io/tempfile.rs | 2 |
4 files changed, 29 insertions, 23 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/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/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 |
