about summary refs log tree commit diff
path: root/src/libstd/io/extensions.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-09-17 10:47:05 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-09-21 21:05:05 -0700
commit81d1feb9804f66034df4f218cc8fb0209c7450a7 (patch)
tree0c524deb8ce5015102af2d2f7a0df93d0fd2f5f7 /src/libstd/io/extensions.rs
parent72841b128df8b6a4eb88b1048548e2eec5244449 (diff)
downloadrust-81d1feb9804f66034df4f218cc8fb0209c7450a7.tar.gz
rust-81d1feb9804f66034df4f218cc8fb0209c7450a7.zip
Remove #[allow(deprecated)] from libstd
Diffstat (limited to 'src/libstd/io/extensions.rs')
-rw-r--r--src/libstd/io/extensions.rs24
1 files changed, 11 insertions, 13 deletions
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()
     }
 }