diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-04-09 11:43:33 +1000 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-04-10 15:21:58 -0700 |
| commit | a65411e4f7b5df78e34dcaf8061d4641f4b56412 (patch) | |
| tree | 3215d5cac2cd39ada18f21d8746dc95765d71b02 /src/libstd/io | |
| parent | 342e8b59be97c28be38d54bec10e511ae17da129 (diff) | |
| download | rust-a65411e4f7b5df78e34dcaf8061d4641f4b56412.tar.gz rust-a65411e4f7b5df78e34dcaf8061d4641f4b56412.zip | |
std,serialize: remove some internal uses of ~[].
These are all private uses of ~[], so can easily & non-controversially be replaced with Vec.
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/extensions.rs | 10 | ||||
| -rw-r--r-- | src/libstd/io/signal.rs | 5 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs index f87f4a69f17..e1eaa2792bf 100644 --- a/src/libstd/io/extensions.rs +++ b/src/libstd/io/extensions.rs @@ -21,7 +21,7 @@ use option::{Option, Some, None}; use result::{Ok, Err}; use io; use io::{IoError, IoResult, Reader}; -use slice::{OwnedVector, ImmutableVector}; +use slice::{OwnedVector, ImmutableVector, Vector}; use ptr::RawPtr; /// An iterator that reads a single byte on each iteration, @@ -88,7 +88,7 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { 8u => f(unsafe { transmute::<i64, [u8, ..8]>(to_le64(n as i64)) }), _ => { - let mut bytes: ~[u8] = ~[]; + let mut bytes = vec!(); let mut i = size; let mut n = n; while i > 0u { @@ -96,7 +96,7 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { n >>= 8_u64; i -= 1u; } - f(bytes) + f(bytes.as_slice()) } } } @@ -127,14 +127,14 @@ pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T { 4u => f(unsafe { transmute::<i32, [u8, ..4]>(to_be32(n as i32)) }), 8u => f(unsafe { transmute::<i64, [u8, ..8]>(to_be64(n as i64)) }), _ => { - let mut bytes: ~[u8] = ~[]; + let mut bytes = vec!(); let mut i = size; while i > 0u { let shift = ((i - 1u) * 8u) as u64; bytes.push((n >> shift) as u8); i -= 1u; } - f(bytes) + f(bytes.as_slice()) } } } diff --git a/src/libstd/io/signal.rs b/src/libstd/io/signal.rs index 6762e7c6a76..00b2e4f2307 100644 --- a/src/libstd/io/signal.rs +++ b/src/libstd/io/signal.rs @@ -29,6 +29,7 @@ use option::{Some, None}; use result::{Ok, Err}; use rt::rtio::{IoFactory, LocalIo, RtioSignal}; use slice::{ImmutableVector, OwnedVector}; +use vec::Vec; /// Signals that can be sent and received #[repr(int)] @@ -80,7 +81,7 @@ pub enum Signum { /// ``` pub struct Listener { /// A map from signums to handles to keep the handles in memory - handles: ~[(Signum, ~RtioSignal:Send)], + handles: Vec<(Signum, ~RtioSignal:Send)>, /// This is where all the handles send signums, which are received by /// the clients from the receiver. tx: Sender<Signum>, @@ -99,7 +100,7 @@ impl Listener { Listener { tx: tx, rx: rx, - handles: ~[], + handles: vec!(), } } |
