diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-10-14 23:05:01 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-10-19 12:59:40 -0700 |
| commit | 9d5d97b55d6487ee23b805bc1acbaa0669b82116 (patch) | |
| tree | b72dcf7045e331e94ea0f8658d088ab42d917935 /src/libstd | |
| parent | fb169d5543c84e11038ba2d07b538ec88fb49ca6 (diff) | |
| download | rust-9d5d97b55d6487ee23b805bc1acbaa0669b82116.tar.gz rust-9d5d97b55d6487ee23b805bc1acbaa0669b82116.zip | |
Remove a large amount of deprecated functionality
Spring cleaning is here! In the Fall! This commit removes quite a large amount of deprecated functionality from the standard libraries. I tried to ensure that only old deprecated functionality was removed. This is removing lots and lots of deprecated features, so this is a breaking change. Please consult the deprecation messages of the deleted code to see how to migrate code forward if it still needs migration. [breaking-change]
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ascii.rs | 52 | ||||
| -rw-r--r-- | src/libstd/collections/hashmap/map.rs | 306 | ||||
| -rw-r--r-- | src/libstd/io/net/udp.rs | 19 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 4 | ||||
| -rw-r--r-- | src/libstd/num/f32.rs | 23 | ||||
| -rw-r--r-- | src/libstd/num/f64.rs | 23 | ||||
| -rw-r--r-- | src/libstd/num/i16.rs | 3 | ||||
| -rw-r--r-- | src/libstd/num/i32.rs | 3 | ||||
| -rw-r--r-- | src/libstd/num/i64.rs | 3 | ||||
| -rw-r--r-- | src/libstd/num/i8.rs | 3 | ||||
| -rw-r--r-- | src/libstd/num/int.rs | 3 | ||||
| -rw-r--r-- | src/libstd/num/int_macros.rs | 50 | ||||
| -rw-r--r-- | src/libstd/num/mod.rs | 7 | ||||
| -rw-r--r-- | src/libstd/num/strconv.rs | 34 | ||||
| -rw-r--r-- | src/libstd/num/u16.rs | 3 | ||||
| -rw-r--r-- | src/libstd/num/u32.rs | 3 | ||||
| -rw-r--r-- | src/libstd/num/u64.rs | 3 | ||||
| -rw-r--r-- | src/libstd/num/u8.rs | 3 | ||||
| -rw-r--r-- | src/libstd/num/uint.rs | 3 | ||||
| -rw-r--r-- | src/libstd/num/uint_macros.rs | 33 | ||||
| -rw-r--r-- | src/libstd/sync/mod.rs | 3 | ||||
| -rw-r--r-- | src/libstd/task.rs | 46 |
22 files changed, 29 insertions, 601 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 1c80627d328..07be15486fd 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -25,13 +25,6 @@ use string::{mod, String}; use to_string::IntoStr; use vec::Vec; -#[deprecated="this trait has been renamed to `AsciiExt`"] -pub use self::AsciiExt as StrAsciiExt; - -#[deprecated="this trait has been renamed to `OwnedAsciiExt`"] -pub use self::OwnedAsciiExt as OwnedStrAsciiExt; - - /// Datatype to hold one ascii character. It wraps a `u8`, with the highest bit always zero. #[deriving(Clone, PartialEq, PartialOrd, Ord, Eq, Hash)] pub struct Ascii { chr: u8 } @@ -49,26 +42,12 @@ impl Ascii { self.chr as char } - #[inline] - #[allow(missing_doc)] - #[deprecated="renamed to `to_lowercase`"] - pub fn to_lower(self) -> Ascii { - self.to_lowercase() - } - /// Convert to lowercase. #[inline] pub fn to_lowercase(self) -> Ascii { Ascii{chr: ASCII_LOWER_MAP[self.chr as uint]} } - /// Deprecated: use `to_uppercase` - #[inline] - #[deprecated="renamed to `to_uppercase`"] - pub fn to_upper(self) -> Ascii { - self.to_uppercase() - } - /// Convert to uppercase. #[inline] pub fn to_uppercase(self) -> Ascii { @@ -83,13 +62,6 @@ impl Ascii { // the following methods are like ctype, and the implementation is inspired by musl - #[inline] - #[allow(missing_doc)] - #[deprecated="renamed to `is_alphabetic`"] - pub fn is_alpha(&self) -> bool { - self.is_alphabetic() - } - /// Check if the character is a letter (a-z, A-Z) #[inline] pub fn is_alphabetic(&self) -> bool { @@ -102,13 +74,6 @@ impl Ascii { self.chr >= 0x30 && self.chr <= 0x39 } - #[inline] - #[allow(missing_doc)] - #[deprecated="renamed to `is_alphanumeric`"] - pub fn is_alnum(&self) -> bool { - self.is_alphanumeric() - } - /// Check if the character is a letter or number #[inline] pub fn is_alphanumeric(&self) -> bool { @@ -139,26 +104,12 @@ impl Ascii { (self.chr - 0x20) < 0x5F } - /// Deprecated: use `to_lowercase` - #[inline] - #[deprecated="renamed to `is_lowercase`"] - pub fn is_lower(&self) -> bool { - self.is_lowercase() - } - /// Checks if the character is lowercase #[inline] pub fn is_lowercase(&self) -> bool { (self.chr - b'a') < 26 } - #[inline] - #[allow(missing_doc)] - #[deprecated="renamed to `is_uppercase`"] - pub fn is_upper(&self) -> bool { - self.is_uppercase() - } - /// Checks if the character is uppercase #[inline] pub fn is_uppercase(&self) -> bool { @@ -581,7 +532,6 @@ mod tests { use prelude::*; use super::*; use char::from_u32; - use vec::Vec; use str::StrSlice; macro_rules! v2ascii ( @@ -590,7 +540,7 @@ mod tests { ) macro_rules! vec2ascii ( - ($($e:expr),*) => (Vec::from_slice([$(Ascii{chr:$e}),*])); + ($($e:expr),*) => ([$(Ascii{chr:$e}),*].to_vec()); ) #[test] diff --git a/src/libstd/collections/hashmap/map.rs b/src/libstd/collections/hashmap/map.rs index bdd9d8d9d1f..ac0d117e02a 100644 --- a/src/libstd/collections/hashmap/map.rs +++ b/src/libstd/collections/hashmap/map.rs @@ -22,7 +22,7 @@ use iter; use mem::replace; use mem; use num; -use ops::{Deref, DerefMut}; +use ops::Deref; use option::{Some, None, Option}; use result::{Ok, Err}; use ops::Index; @@ -425,25 +425,6 @@ impl<K, V, M> SearchResult<K, V, M> { } } -/// A newtyped mutable reference to the hashmap that allows e.g. Deref to be -/// implemented without making changes to the visible interface of HashMap. -/// Used internally because it's accepted by the search functions above. -struct MapMutRef<'a, K: 'a, V: 'a, H: 'a> { - map_ref: &'a mut HashMap<K, V, H> -} - -impl<'a, K, V, H> Deref<RawTable<K, V>> for MapMutRef<'a, K, V, H> { - fn deref(&self) -> &RawTable<K, V> { - &self.map_ref.table - } -} - -impl<'a, K, V, H> DerefMut<RawTable<K, V>> for MapMutRef<'a, K, V, H> { - fn deref_mut(&mut self) -> &mut RawTable<K, V> { - &mut self.map_ref.table - } -} - impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> { fn make_hash<X: Hash<S>>(&self, x: &X) -> SafeHash { table::make_hash(&self.hasher, x) @@ -847,253 +828,6 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> { } } - /// Inserts an element which has already been hashed, returning a reference - /// to that element inside the hashtable. This is more efficient that using - /// `insert`, since the key will not be rehashed. - fn insert_hashed(&mut self, hash: SafeHash, k: K, v: V) -> &mut V { - let potential_new_size = self.table.size() + 1; - self.make_some_room(potential_new_size); - self.insert_hashed_nocheck(hash, k, v) - } - - /// Deprecated: use `entry` as follows instead: - /// - /// ``` - /// use std::collections::HashMap; - /// use std::collections::hashmap::{Occupied, Vacant}; - /// - /// let mut map = HashMap::new(); - /// - /// let result = match map.entry("a") { - /// Vacant(entry) => entry.set(1i), - /// Occupied(entry) => entry.into_mut(), - /// }; - /// assert_eq!(*result, 1); - /// ``` - /// - /// Return the value corresponding to the key in the map, or insert - /// and return the value if it doesn't exist. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// use std::collections::HashMap; - /// let mut map = HashMap::new(); - /// - /// // Insert 1i with key "a" - /// assert_eq!(*map.find_or_insert("a", 1i), 1); - /// - /// // Find the existing key - /// assert_eq!(*map.find_or_insert("a", -2), 1); - /// ``` - #[deprecated = "use entry instead"] - #[allow(deprecated)] - pub fn find_or_insert(&mut self, k: K, v: V) -> &mut V { - self.find_with_or_insert_with(k, v, |_k, _v, _a| (), |_k, a| a) - } - - /// Deprecated: use `entry` as follows instead: - /// - /// ``` - /// use std::collections::HashMap; - /// use std::collections::hashmap::{Occupied, Vacant}; - /// - /// let mut map = HashMap::new(); - /// - /// let result = match map.entry("a") { - /// Vacant(entry) => entry.set(1i), - /// Occupied(entry) => entry.into_mut(), - /// }; - /// assert_eq!(*result, 1); - /// ``` - /// - /// Return the value corresponding to the key in the map, or create, - /// insert, and return a new value if it doesn't exist. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// use std::collections::HashMap; - /// let mut map = HashMap::new(); - /// - /// // Insert 10 with key 2 - /// assert_eq!(*map.find_or_insert_with(2i, |&key| 5 * key as uint), 10u); - /// - /// // Find the existing key - /// assert_eq!(*map.find_or_insert_with(2, |&key| key as uint), 10); - /// ``` - #[deprecated = "use entry instead"] - #[allow(deprecated)] - pub fn find_or_insert_with<'a>(&'a mut self, k: K, f: |&K| -> V) - -> &'a mut V { - self.find_with_or_insert_with(k, (), |_k, _v, _a| (), |k, _a| f(k)) - } - - /// Deprecated: use `entry` as follows instead: - /// - /// ``` - /// use std::collections::HashMap; - /// use std::collections::hashmap::{Occupied, Vacant}; - /// - /// let mut map = HashMap::new(); - /// - /// let result = match map.entry("a") { - /// Vacant(entry) => entry.set(1u), - /// Occupied(mut entry) => { - /// *entry.get_mut() += 1; - /// entry.into_mut() - /// } - /// }; - /// assert_eq!(*result, 1); - /// ``` - /// - /// Insert a key-value pair into the map if the key is not already present. - /// Otherwise, modify the existing value for the key. - /// Returns the new or modified value for the key. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// use std::collections::HashMap; - /// let mut map = HashMap::new(); - /// - /// // Insert 2 with key "a" - /// assert_eq!(*map.insert_or_update_with("a", 2u, |_key, val| *val = 3), 2); - /// - /// // Update and return the existing value - /// assert_eq!(*map.insert_or_update_with("a", 9, |_key, val| *val = 7), 7); - /// assert_eq!(map["a"], 7); - /// ``` - #[deprecated = "use entry instead"] - pub fn insert_or_update_with<'a>( - &'a mut self, - k: K, - v: V, - f: |&K, &mut V|) - -> &'a mut V { - let potential_new_size = self.table.size() + 1; - self.make_some_room(potential_new_size); - - let hash = self.make_hash(&k); - self.insert_or_replace_with(hash, k, v, |kref, vref, _v| f(kref, vref)) - } - - /// Deprecated: use `entry` as follows instead: - /// - /// ``` - /// use std::collections::HashMap; - /// use std::collections::hashmap::{Occupied, Vacant}; - /// - /// let mut map = HashMap::new(); - /// - /// let result = match map.entry("a") { - /// Vacant(entry) => entry.set(1u), - /// Occupied(mut entry) => { - /// *entry.get_mut() += 1; - /// entry.into_mut() - /// } - /// }; - /// assert_eq!(*result, 1); - /// ``` - /// - /// Modify and return the value corresponding to the key in the map, or - /// insert and return a new value if it doesn't exist. - /// - /// This method allows for all insertion behaviours of a hashmap; - /// see methods like - /// [`insert`](../trait.MutableMap.html#tymethod.insert), - /// [`find_or_insert`](#method.find_or_insert) and - /// [`insert_or_update_with`](#method.insert_or_update_with) - /// for less general and more friendly variations of this. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// use std::collections::HashMap; - /// - /// // map some strings to vectors of strings - /// let mut map = HashMap::new(); - /// map.insert("a key", vec!["value"]); - /// map.insert("z key", vec!["value"]); - /// - /// let new = vec!["a key", "b key", "z key"]; - /// - /// for k in new.into_iter() { - /// map.find_with_or_insert_with( - /// k, "new value", - /// // if the key does exist either prepend or append this - /// // new value based on the first letter of the key. - /// |key, already, new| { - /// if key.as_slice().starts_with("z") { - /// already.insert(0, new); - /// } else { - /// already.push(new); - /// } - /// }, - /// // if the key doesn't exist in the map yet, add it in - /// // the obvious way. - /// |_k, v| vec![v]); - /// } - /// - /// assert_eq!(map.len(), 3); - /// assert_eq!(map["a key"], vec!["value", "new value"]); - /// assert_eq!(map["b key"], vec!["new value"]); - /// assert_eq!(map["z key"], vec!["new value", "value"]); - /// ``` - #[deprecated = "use entry instead"] - pub fn find_with_or_insert_with<'a, A>(&'a mut self, - k: K, - a: A, - found: |&K, &mut V, A|, - not_found: |&K, A| -> V) - -> &'a mut V - { - let hash = self.make_hash(&k); - let this = MapMutRef { map_ref: self }; - - match search_hashed(this, &hash, &k) { - FoundExisting(bucket) => { - let (_, v_ref) = bucket.into_mut_refs(); - found(&k, v_ref, a); - v_ref - } - TableRef(this) => { - let v = not_found(&k, a); - this.map_ref.insert_hashed(hash, k, v) - } - } - } - - /// Retrieves a value for the given key. - /// See [`find`](../trait.Map.html#tymethod.find) for a non-failing alternative. - /// - /// # Failure - /// - /// Fails if the key is not present. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// - /// use std::collections::HashMap; - /// - /// let mut map = HashMap::new(); - /// map.insert("a", 1i); - /// assert_eq!(map.get(&"a"), &1); - /// ``` - #[deprecated = "prefer indexing instead, e.g., map[key]"] - pub fn get<'a>(&'a self, k: &K) -> &'a V { - match self.find(k) { - Some(v) => v, - None => fail!("no entry found for key") - } - } - /// Retrieves a mutable value for the given key. /// See [`find_mut`](../trait.MutableMap.html#tymethod.find_mut) for a non-failing alternative. /// @@ -1274,12 +1008,6 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> { Entries { inner: self.table.iter() } } - /// Deprecated: use `iter_mut`. - #[deprecated = "use iter_mut"] - pub fn mut_iter(&mut self) -> MutEntries<K, V> { - self.iter_mut() - } - /// An iterator visiting all key-value pairs in arbitrary order, /// with mutable references to the values. /// Iterator element type is `(&'a K, &'a mut V)`. @@ -1307,12 +1035,6 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> { MutEntries { inner: self.table.iter_mut() } } - /// Deprecated: use `into_iter`. - #[deprecated = "use into_iter"] - pub fn move_iter(self) -> MoveEntries<K, V> { - self.into_iter() - } - /// Creates a consuming iterator, that is, one that moves each key-value /// pair out of the map in arbitrary order. The map cannot be used after /// calling this. @@ -1468,9 +1190,8 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H> impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> Index<K, V> for HashMap<K, V, H> { #[inline] - #[allow(deprecated)] fn index<'a>(&'a self, index: &K) -> &'a V { - self.get(index) + self.find(index).expect("no entry found for key") } } @@ -1930,29 +1651,6 @@ mod test_map { } #[test] - #[allow(deprecated)] // insert_or_update_with - fn test_update_with() { - let mut m = HashMap::with_capacity(4); - assert!(m.insert(1i, 2i)); - - for i in range(1i, 1000) { - assert_eq!( - i + 2, - *m.insert_or_update_with(i + 1, i + 2, |_k, _v| { - fail!("Key not yet present"); - }) - ); - assert_eq!( - i + 1, - *m.insert_or_update_with(i, i + 3, |k, v| { - assert_eq!(*k, i); - assert_eq!(*v, i + 1); - }) - ); - } - } - - #[test] fn test_conflict_remove() { let mut m = HashMap::with_capacity(4); assert!(m.insert(1i, 2i)); diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index b8fb187548c..53e60d553be 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -85,13 +85,6 @@ impl UdpSocket { } } - #[allow(missing_doc)] - #[deprecated = "renamed to `recv_from`"] - pub fn recvfrom(&mut self, buf: &mut [u8]) - -> IoResult<(uint, SocketAddr)> { - self.recv_from(buf) - } - /// Sends data on the socket to the given address. Returns nothing on /// success. pub fn send_to(&mut self, buf: &[u8], dst: SocketAddr) -> IoResult<()> { @@ -101,12 +94,6 @@ impl UdpSocket { }).map_err(IoError::from_rtio_error) } - #[allow(missing_doc)] - #[deprecated = "renamed to `send_to`"] - pub fn sendto(&mut self, buf: &[u8], dst: SocketAddr) -> IoResult<()> { - self.send_to(buf, dst) - } - /// Creates a `UdpStream`, which allows use of the `Reader` and `Writer` /// traits to receive and send data from the same address. This transfers /// ownership of the socket to the stream. @@ -176,12 +163,6 @@ impl UdpSocket { }.map_err(IoError::from_rtio_error) } - /// Sets the broadcast flag on or off - #[deprecated="renamed to `set_broadcast`"] - pub fn set_broadast(&mut self, broadcast: bool) -> IoResult<()> { - self.set_broadcast(broadcast) - } - /// Sets the read/write timeout for this socket. /// /// For more information, see `TcpStream::set_timeout` diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 82c8d8071b3..c47cd025994 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -134,7 +134,6 @@ extern crate rustrt; #[cfg(test)] pub use realstd::kinds; #[cfg(test)] pub use realstd::ops; #[cfg(test)] pub use realstd::cmp; -#[cfg(test)] pub use realstd::ty; #[cfg(test)] pub use realstd::boxed; @@ -159,13 +158,10 @@ pub use core::tuple; // FIXME #15320: primitive documentation needs top-level modules, this // should be `std::tuple::unit`. pub use core::unit; -#[cfg(not(test))] pub use core::ty; pub use core::result; pub use core::option; pub use alloc::boxed; -#[deprecated = "use boxed instead"] -pub use boxed as owned; pub use alloc::rc; diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index b2a9f1b7b20..92db94c5e9a 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -333,29 +333,6 @@ pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String { r } -impl num::ToStrRadix for f32 { - /// Converts a float to a string in a given radix - /// - /// # Arguments - /// - /// * num - The float value - /// * radix - The base to use - /// - /// # Failure - /// - /// Fails if called on a special value like `inf`, `-inf` or `NaN` due to - /// possible misinterpretation of the result at higher bases. If those values - /// are expected, use `to_str_radix_special()` instead. - #[inline] - fn to_str_radix(&self, rdx: uint) -> String { - let (r, special) = strconv::float_to_str_common( - *self, rdx, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false); - if special { fail!("number has a special value, \ - try to_str_radix_special() if those are expected") } - r - } -} - /// Convert a string in base 16 to a float. /// Accepts an optional binary exponent. /// diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 6fe9fcad2aa..3635c3192db 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -341,29 +341,6 @@ pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String { r } -impl num::ToStrRadix for f64 { - /// Converts a float to a string in a given radix - /// - /// # Arguments - /// - /// * num - The float value - /// * radix - The base to use - /// - /// # Failure - /// - /// Fails if called on a special value like `inf`, `-inf` or `NAN` due to - /// possible misinterpretation of the result at higher bases. If those values - /// are expected, use `to_str_radix_special()` instead. - #[inline] - fn to_str_radix(&self, rdx: uint) -> String { - let (r, special) = strconv::float_to_str_common( - *self, rdx, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false); - if special { fail!("number has a special value, \ - try to_str_radix_special() if those are expected") } - r - } -} - /// Convert a string in base 16 to a float. /// Accepts an optional binary exponent. /// diff --git a/src/libstd/num/i16.rs b/src/libstd/num/i16.rs index 9e4cc06f0a2..d7732b474db 100644 --- a/src/libstd/num/i16.rs +++ b/src/libstd/num/i16.rs @@ -14,10 +14,9 @@ #![doc(primitive = "i16")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::i16::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/i32.rs b/src/libstd/num/i32.rs index 54259fcad55..778f1c6748c 100644 --- a/src/libstd/num/i32.rs +++ b/src/libstd/num/i32.rs @@ -14,10 +14,9 @@ #![doc(primitive = "i32")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::i32::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/i64.rs b/src/libstd/num/i64.rs index b5fe6825ca4..ae3d57eeac6 100644 --- a/src/libstd/num/i64.rs +++ b/src/libstd/num/i64.rs @@ -14,10 +14,9 @@ #![doc(primitive = "i64")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::i64::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs index 7aa9a41e340..8a3f379893c 100644 --- a/src/libstd/num/i8.rs +++ b/src/libstd/num/i8.rs @@ -14,10 +14,9 @@ #![doc(primitive = "i8")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::i8::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/int.rs b/src/libstd/num/int.rs index 74ee61634c6..51af04b32d4 100644 --- a/src/libstd/num/int.rs +++ b/src/libstd/num/int.rs @@ -14,10 +14,9 @@ #![doc(primitive = "int")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::int::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 62e609bb2e1..ca45b40e687 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -51,52 +51,12 @@ impl FromStrRadix for $T { } } -// String conversion functions and impl num -> str - -/// Convert to a string as a byte slice in a given base. -/// -/// Use in place of x.to_string() when you do not need to store the string permanently -/// -/// # Examples -/// -/// ``` -/// #![allow(deprecated)] -/// -/// std::int::to_str_bytes(123, 10, |v| { -/// assert!(v == "123".as_bytes()); -/// }); -/// ``` -#[inline] -#[deprecated = "just use .to_string(), or a BufWriter with write! if you mustn't allocate"] -pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U { - use io::{Writer, Seek}; - // The radix can be as low as 2, so we need at least 64 characters for a - // base 2 number, and then we need another for a possible '-' character. - let mut buf = [0u8, ..65]; - let amt = { - let mut wr = ::io::BufWriter::new(buf); - (write!(&mut wr, "{}", ::fmt::radix(n, radix as u8))).unwrap(); - wr.tell().unwrap() as uint - }; - f(buf[..amt]) -} - -#[deprecated = "use fmt::radix"] -impl ToStrRadix for $T { - /// Convert to a string in a given base. - #[inline] - fn to_str_radix(&self, radix: uint) -> String { - format!("{}", ::fmt::radix(*self, radix as u8)) - } -} - #[cfg(test)] mod tests { use prelude::*; use super::*; use i32; - use num::ToStrRadix; use str::StrSlice; #[test] @@ -143,16 +103,6 @@ mod tests { } #[test] - fn test_to_string() { - assert_eq!((0 as $T).to_str_radix(10u), "0".to_string()); - assert_eq!((1 as $T).to_str_radix(10u), "1".to_string()); - assert_eq!((-1 as $T).to_str_radix(10u), "-1".to_string()); - assert_eq!((127 as $T).to_str_radix(16u), "7f".to_string()); - assert_eq!((100 as $T).to_str_radix(10u), "100".to_string()); - - } - - #[test] fn test_int_to_str_overflow() { let mut i8_val: i8 = 127_i8; assert_eq!(i8_val.to_string(), "127".to_string()); diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index 27ee1e3ce3b..564b6a25f7f 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -17,7 +17,6 @@ #![allow(missing_doc)] use option::Option; -use string::String; #[cfg(test)] use fmt::Show; @@ -111,12 +110,6 @@ pub trait FloatMath: Float { fn atanh(self) -> Self; } -/// A generic trait for converting a value to a string with a radix (base) -#[deprecated = "use fmt::radix"] -pub trait ToStrRadix { - fn to_str_radix(&self, radix: uint) -> String; -} - /// A generic trait for converting a string with a radix (base) to a value #[experimental = "might need to return Result"] pub trait FromStrRadix { diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 48ee7664c16..af66e6ca934 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -20,7 +20,7 @@ use num::{Float, FPNaN, FPInfinite, ToPrimitive}; use num; use ops::{Add, Sub, Mul, Div, Rem, Neg}; use option::{None, Option, Some}; -use slice::{ImmutableSlice, MutableSlice}; +use slice::{ImmutableSlice, MutableSlice, CloneableVector}; use std::cmp::{PartialOrd, PartialEq}; use str::StrSlice; use string::String; @@ -168,8 +168,7 @@ static NAN_BUF: [u8, ..3] = [b'N', b'a', b'N']; * # Failure * - Fails if `radix` < 2 or `radix` > 36. */ -#[deprecated = "format!() and friends should be favored instead"] -pub fn int_to_str_bytes_common<T: Int>(num: T, radix: uint, sign: SignFormat, f: |u8|) { +fn int_to_str_bytes_common<T: Int>(num: T, radix: uint, sign: SignFormat, f: |u8|) { assert!(2 <= radix && radix <= 36); let _0: T = Zero::zero(); @@ -257,7 +256,6 @@ pub fn int_to_str_bytes_common<T: Int>(num: T, radix: uint, sign: SignFormat, f: * - Fails if `radix` > 25 and `exp_format` is `ExpBin` due to conflict * between digit and exponent sign `'p'`. */ -#[allow(deprecated)] pub fn float_to_str_bytes_common<T:NumCast+Zero+One+PartialEq+PartialOrd+Float+ Div<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>( num: T, radix: uint, negative_zero: bool, @@ -278,17 +276,17 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+PartialEq+PartialOrd+Float+ let _1: T = One::one(); match num.classify() { - FPNaN => { return (Vec::from_slice("NaN".as_bytes()), true); } + FPNaN => { return (b"NaN".to_vec(), true); } FPInfinite if num > _0 => { return match sign { - SignAll => (Vec::from_slice("+inf".as_bytes()), true), - _ => (Vec::from_slice("inf".as_bytes()), true) + SignAll => (b"+inf".to_vec(), true), + _ => (b"inf".to_vec(), true) }; } FPInfinite if num < _0 => { return match sign { - SignNone => (Vec::from_slice("inf".as_bytes()), true), - _ => (Vec::from_slice("-inf".as_bytes()), true), + SignNone => (b"inf".to_vec(), true), + _ => (b"-inf".to_vec(), true), }; } _ => {} @@ -413,18 +411,18 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+PartialEq+PartialOrd+Float+ // If reached left end of number, have to // insert additional digit: if i < 0 - || *buf.get(i as uint) == b'-' - || *buf.get(i as uint) == b'+' { + || buf[i as uint] == b'-' + || buf[i as uint] == b'+' { buf.insert((i + 1) as uint, value2ascii(1)); break; } // Skip the '.' - if *buf.get(i as uint) == b'.' { i -= 1; continue; } + if buf[i as uint] == b'.' { i -= 1; continue; } // Either increment the digit, // or set to 0 if max and carry the 1. - let current_digit = ascii2value(*buf.get(i as uint)); + let current_digit = ascii2value(buf[i as uint]); if current_digit < (radix - 1) { *buf.get_mut(i as uint) = value2ascii(current_digit+1); break; @@ -446,25 +444,25 @@ pub fn float_to_str_bytes_common<T:NumCast+Zero+One+PartialEq+PartialOrd+Float+ let mut i = buf_max_i; // discover trailing zeros of fractional part - while i > start_fractional_digits && *buf.get(i) == b'0' { + while i > start_fractional_digits && buf[i] == b'0' { i -= 1; } // Only attempt to truncate digits if buf has fractional digits if i >= start_fractional_digits { // If buf ends with '.', cut that too. - if *buf.get(i) == b'.' { i -= 1 } + if buf[i] == b'.' { i -= 1 } // only resize buf if we actually remove digits if i < buf_max_i { - buf = Vec::from_slice(buf.slice(0, i + 1)); + buf = buf.slice(0, i + 1).to_vec(); } } } // If exact and trailing '.', just cut that else { let max_i = buf.len() - 1; - if *buf.get(max_i) == b'.' { - buf = Vec::from_slice(buf.slice(0, max_i)); + if buf[max_i] == b'.' { + buf = buf.slice(0, max_i).to_vec(); } } diff --git a/src/libstd/num/u16.rs b/src/libstd/num/u16.rs index c141ecc9cba..bb619b5b2f5 100644 --- a/src/libstd/num/u16.rs +++ b/src/libstd/num/u16.rs @@ -14,10 +14,9 @@ #![doc(primitive = "u16")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::u16::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/u32.rs b/src/libstd/num/u32.rs index 8a8e2729a53..754103ba5da 100644 --- a/src/libstd/num/u32.rs +++ b/src/libstd/num/u32.rs @@ -14,10 +14,9 @@ #![doc(primitive = "u32")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::u32::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/u64.rs b/src/libstd/num/u64.rs index 1b4f8bc433f..da497d2cbe4 100644 --- a/src/libstd/num/u64.rs +++ b/src/libstd/num/u64.rs @@ -14,10 +14,9 @@ #![doc(primitive = "u64")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::u64::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/u8.rs b/src/libstd/num/u8.rs index 28f22429235..bdfcdb2c5a5 100644 --- a/src/libstd/num/u8.rs +++ b/src/libstd/num/u8.rs @@ -14,10 +14,9 @@ #![doc(primitive = "u8")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::u8::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index da328074453..5090219d3de 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -14,10 +14,9 @@ #![doc(primitive = "uint")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::uint::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index a033308af16..f9bc9eb539a 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -82,36 +82,15 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U { f(buf[..amt]) } -#[deprecated = "use fmt::radix"] -impl ToStrRadix for $T { - /// Convert to a string in a given base. - #[inline] - fn to_str_radix(&self, radix: uint) -> String { - format!("{}", ::fmt::radix(*self, radix as u8)) - } -} - #[cfg(test)] mod tests { use prelude::*; use super::*; - use num::ToStrRadix; use str::StrSlice; use u16; #[test] - pub fn test_to_string() { - assert_eq!((0 as $T).to_str_radix(10u), "0".to_string()); - assert_eq!((1 as $T).to_str_radix(10u), "1".to_string()); - assert_eq!((2 as $T).to_str_radix(10u), "2".to_string()); - assert_eq!((11 as $T).to_str_radix(10u), "11".to_string()); - assert_eq!((11 as $T).to_str_radix(16u), "b".to_string()); - assert_eq!((255 as $T).to_str_radix(16u), "ff".to_string()); - assert_eq!((0xff as $T).to_str_radix(10u), "255".to_string()); - } - - #[test] pub fn test_from_str() { assert_eq!(from_str::<$T>("0"), Some(0u as $T)); assert_eq!(from_str::<$T>("3"), Some(3u as $T)); @@ -199,18 +178,6 @@ mod tests { assert_eq!(from_str::<u64>("0"), Some(u64_val)); assert!(from_str::<u64>("-1").is_none()); } - - #[test] - #[should_fail] - pub fn to_str_radix1() { - 100u.to_str_radix(1u); - } - - #[test] - #[should_fail] - pub fn to_str_radix37() { - 100u.to_str_radix(37u); - } } )) diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs index 8cfa1ebd598..38e1e952f77 100644 --- a/src/libstd/sync/mod.rs +++ b/src/libstd/sync/mod.rs @@ -26,9 +26,6 @@ pub use core_sync::{RWLock, RWLockReadGuard, RWLockWriteGuard}; pub use core_sync::{Semaphore, SemaphoreGuard}; pub use core_sync::one::{Once, ONCE_INIT}; -#[deprecated = "use atomic instead"] -pub use core_sync::atomic as atomics; - pub use self::future::Future; pub use self::task_pool::TaskPool; diff --git a/src/libstd/task.rs b/src/libstd/task.rs index 04d3bb8b3a7..1d1e6ae4feb 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -225,26 +225,6 @@ impl<S: Spawner> TaskBuilder<S> { } } - /// Add a wrapper to the body of the spawned task. - /// - /// Before the task is spawned it is passed through a 'body generator' - /// function that may perform local setup operations as well as wrap - /// the task body in remote setup operations. With this the behavior - /// of tasks can be extended in simple ways. - /// - /// This function augments the current body generator with a new body - /// generator by applying the task body which results from the - /// existing body generator to the new body generator. - #[deprecated = "this function will be removed soon"] - pub fn with_wrapper(mut self, wrapper: proc(v: proc():Send):Send -> proc():Send) - -> TaskBuilder<S> { - self.gen_body = match self.gen_body.take() { - Some(prev) => Some(proc(body) { wrapper(prev(body)) }), - None => Some(wrapper) - }; - self - } - // Where spawning actually happens (whether yielding a future or not) fn spawn_internal(self, f: proc():Send, on_exit: Option<proc(Result<(), Box<Any + Send>>):Send>) { @@ -354,18 +334,6 @@ pub fn try_future<T:Send>(f: proc():Send -> T) -> Future<Result<T, Box<Any + Sen /* Lifecycle functions */ /// Read the name of the current task. -#[deprecated = "Use `task::name()`."] -pub fn with_task_name<U>(blk: |Option<&str>| -> U) -> U { - use rt::task::Task; - - let task = Local::borrow(None::<Task>); - match task.name { - Some(ref name) => blk(Some(name.as_slice())), - None => blk(None) - } -} - -/// Read the name of the current task. #[stable] pub fn name() -> Option<String> { use rt::task::Task; @@ -447,20 +415,6 @@ mod test { } #[test] - #[allow(deprecated)] - fn test_with_wrapper() { - let (tx, rx) = channel(); - TaskBuilder::new().with_wrapper(proc(body) { - let result: proc():Send = proc() { - body(); - tx.send(()); - }; - result - }).spawn(proc() { }); - rx.recv(); - } - - #[test] fn test_try_future() { let result = TaskBuilder::new().try_future(proc() {}); assert!(result.unwrap().is_ok()); |
