diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-01-01 23:53:35 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-03 23:43:57 -0800 |
| commit | 7d8d06f86b48520814596bd5363d2b82bc619774 (patch) | |
| tree | eda093ca208286fd8679da8de9f3597b7a024c50 /src/libcore | |
| parent | 470118f3e915cdc8f936aca0640b28a7a3d8dc6c (diff) | |
| download | rust-7d8d06f86b48520814596bd5363d2b82bc619774.tar.gz rust-7d8d06f86b48520814596bd5363d2b82bc619774.zip | |
Remove deprecated functionality
This removes a large array of deprecated functionality, regardless of how recently it was deprecated. The purpose of this commit is to clean out the standard libraries and compiler for the upcoming alpha release. Some notable compiler changes were to enable warnings for all now-deprecated command line arguments (previously the deprecated versions were silently accepted) as well as removing deriving(Zero) entirely (the trait was removed). The distribution no longer contains the libtime or libregex_macros crates. Both of these have been deprecated for some time and are available externally.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/atomic.rs | 178 | ||||
| -rw-r--r-- | src/libcore/cell.rs | 8 | ||||
| -rw-r--r-- | src/libcore/char.rs | 121 | ||||
| -rw-r--r-- | src/libcore/cmp.rs | 10 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 11 | ||||
| -rw-r--r-- | src/libcore/num/f32.rs | 76 | ||||
| -rw-r--r-- | src/libcore/num/f64.rs | 76 | ||||
| -rw-r--r-- | src/libcore/num/mod.rs | 209 | ||||
| -rw-r--r-- | src/libcore/ptr.rs | 47 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 78 | ||||
| -rw-r--r-- | src/libcore/str/mod.rs | 119 | ||||
| -rw-r--r-- | src/libcore/tuple.rs | 38 |
12 files changed, 132 insertions, 839 deletions
diff --git a/src/libcore/atomic.rs b/src/libcore/atomic.rs index 5d3bcb19ae8..0ac0dc396cc 100644 --- a/src/libcore/atomic.rs +++ b/src/libcore/atomic.rs @@ -8,7 +8,65 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Core atomic primitives +//! Atomic types +//! +//! Atomic types provide primitive shared-memory communication between +//! threads, and are the building blocks of other concurrent +//! types. +//! +//! This module defines atomic versions of a select number of primitive +//! types, including `AtomicBool`, `AtomicInt`, `AtomicUint`, and `AtomicOption`. +//! Atomic types present operations that, when used correctly, synchronize +//! updates between threads. +//! +//! Each method takes an `Ordering` which represents the strength of +//! the memory barrier for that operation. These orderings are the +//! same as [C++11 atomic orderings][1]. +//! +//! [1]: http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync +//! +//! Atomic variables are safe to share between threads (they implement `Sync`) +//! but they do not themselves provide the mechanism for sharing. The most +//! common way to share an atomic variable is to put it into an `Arc` (an +//! atomically-reference-counted shared pointer). +//! +//! Most atomic types may be stored in static variables, initialized using +//! the provided static initializers like `INIT_ATOMIC_BOOL`. Atomic statics +//! are often used for lazy global initialization. +//! +//! +//! # Examples +//! +//! A simple spinlock: +//! +//! ``` +//! use std::sync::Arc; +//! use std::sync::atomic::{AtomicUint, Ordering}; +//! use std::thread::Thread; +//! +//! fn main() { +//! let spinlock = Arc::new(AtomicUint::new(1)); +//! +//! let spinlock_clone = spinlock.clone(); +//! Thread::spawn(move|| { +//! spinlock_clone.store(0, Ordering::SeqCst); +//! }).detach(); +//! +//! // Wait for the other task to release the lock +//! while spinlock.load(Ordering::SeqCst) != 0 {} +//! } +//! ``` +//! +//! Keep a global count of live tasks: +//! +//! ``` +//! use std::sync::atomic::{AtomicUint, Ordering, ATOMIC_UINT_INIT}; +//! +//! static GLOBAL_TASK_COUNT: AtomicUint = ATOMIC_UINT_INIT; +//! +//! let old_task_count = GLOBAL_TASK_COUNT.fetch_add(1, Ordering::SeqCst); +//! println!("live tasks: {}", old_task_count + 1); +//! ``` #![stable] @@ -235,19 +293,19 @@ impl AtomicBool { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicBool, SeqCst}; + /// use std::sync::atomic::{AtomicBool, Ordering}; /// /// let foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_and(false, SeqCst)); - /// assert_eq!(false, foo.load(SeqCst)); + /// assert_eq!(true, foo.fetch_and(false, Ordering::SeqCst)); + /// assert_eq!(false, foo.load(Ordering::SeqCst)); /// /// let foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_and(true, SeqCst)); - /// assert_eq!(true, foo.load(SeqCst)); + /// assert_eq!(true, foo.fetch_and(true, Ordering::SeqCst)); + /// assert_eq!(true, foo.load(Ordering::SeqCst)); /// /// let foo = AtomicBool::new(false); - /// assert_eq!(false, foo.fetch_and(false, SeqCst)); - /// assert_eq!(false, foo.load(SeqCst)); + /// assert_eq!(false, foo.fetch_and(false, Ordering::SeqCst)); + /// assert_eq!(false, foo.load(Ordering::SeqCst)); /// ``` #[inline] #[stable] @@ -267,20 +325,20 @@ impl AtomicBool { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicBool, SeqCst}; + /// use std::sync::atomic::{AtomicBool, Ordering}; /// /// let foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_nand(false, SeqCst)); - /// assert_eq!(true, foo.load(SeqCst)); + /// assert_eq!(true, foo.fetch_nand(false, Ordering::SeqCst)); + /// assert_eq!(true, foo.load(Ordering::SeqCst)); /// /// let foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_nand(true, SeqCst)); - /// assert_eq!(0, foo.load(SeqCst) as int); - /// assert_eq!(false, foo.load(SeqCst)); + /// assert_eq!(true, foo.fetch_nand(true, Ordering::SeqCst)); + /// assert_eq!(0, foo.load(Ordering::SeqCst) as int); + /// assert_eq!(false, foo.load(Ordering::SeqCst)); /// /// let foo = AtomicBool::new(false); - /// assert_eq!(false, foo.fetch_nand(false, SeqCst)); - /// assert_eq!(true, foo.load(SeqCst)); + /// assert_eq!(false, foo.fetch_nand(false, Ordering::SeqCst)); + /// assert_eq!(true, foo.load(Ordering::SeqCst)); /// ``` #[inline] #[stable] @@ -300,19 +358,19 @@ impl AtomicBool { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicBool, SeqCst}; + /// use std::sync::atomic::{AtomicBool, Ordering}; /// /// let foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_or(false, SeqCst)); - /// assert_eq!(true, foo.load(SeqCst)); + /// assert_eq!(true, foo.fetch_or(false, Ordering::SeqCst)); + /// assert_eq!(true, foo.load(Ordering::SeqCst)); /// /// let foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_or(true, SeqCst)); - /// assert_eq!(true, foo.load(SeqCst)); + /// assert_eq!(true, foo.fetch_or(true, Ordering::SeqCst)); + /// assert_eq!(true, foo.load(Ordering::SeqCst)); /// /// let foo = AtomicBool::new(false); - /// assert_eq!(false, foo.fetch_or(false, SeqCst)); - /// assert_eq!(false, foo.load(SeqCst)); + /// assert_eq!(false, foo.fetch_or(false, Ordering::SeqCst)); + /// assert_eq!(false, foo.load(Ordering::SeqCst)); /// ``` #[inline] #[stable] @@ -332,19 +390,19 @@ impl AtomicBool { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicBool, SeqCst}; + /// use std::sync::atomic::{AtomicBool, Ordering}; /// /// let foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_xor(false, SeqCst)); - /// assert_eq!(true, foo.load(SeqCst)); + /// assert_eq!(true, foo.fetch_xor(false, Ordering::SeqCst)); + /// assert_eq!(true, foo.load(Ordering::SeqCst)); /// /// let foo = AtomicBool::new(true); - /// assert_eq!(true, foo.fetch_xor(true, SeqCst)); - /// assert_eq!(false, foo.load(SeqCst)); + /// assert_eq!(true, foo.fetch_xor(true, Ordering::SeqCst)); + /// assert_eq!(false, foo.load(Ordering::SeqCst)); /// /// let foo = AtomicBool::new(false); - /// assert_eq!(false, foo.fetch_xor(false, SeqCst)); - /// assert_eq!(false, foo.load(SeqCst)); + /// assert_eq!(false, foo.fetch_xor(false, Ordering::SeqCst)); + /// assert_eq!(false, foo.load(Ordering::SeqCst)); /// ``` #[inline] #[stable] @@ -463,11 +521,11 @@ impl AtomicInt { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicInt, SeqCst}; + /// use std::sync::atomic::{AtomicInt, Ordering}; /// /// let foo = AtomicInt::new(0); - /// assert_eq!(0, foo.fetch_add(10, SeqCst)); - /// assert_eq!(10, foo.load(SeqCst)); + /// assert_eq!(0, foo.fetch_add(10, Ordering::SeqCst)); + /// assert_eq!(10, foo.load(Ordering::SeqCst)); /// ``` #[inline] #[stable] @@ -480,11 +538,11 @@ impl AtomicInt { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicInt, SeqCst}; + /// use std::sync::atomic::{AtomicInt, Ordering}; /// /// let foo = AtomicInt::new(0); - /// assert_eq!(0, foo.fetch_sub(10, SeqCst)); - /// assert_eq!(-10, foo.load(SeqCst)); + /// assert_eq!(0, foo.fetch_sub(10, Ordering::SeqCst)); + /// assert_eq!(-10, foo.load(Ordering::SeqCst)); /// ``` #[inline] #[stable] @@ -497,11 +555,11 @@ impl AtomicInt { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicInt, SeqCst}; + /// use std::sync::atomic::{AtomicInt, Ordering}; /// /// let foo = AtomicInt::new(0b101101); - /// assert_eq!(0b101101, foo.fetch_and(0b110011, SeqCst)); - /// assert_eq!(0b100001, foo.load(SeqCst)); + /// assert_eq!(0b101101, foo.fetch_and(0b110011, Ordering::SeqCst)); + /// assert_eq!(0b100001, foo.load(Ordering::SeqCst)); #[inline] #[stable] pub fn fetch_and(&self, val: int, order: Ordering) -> int { @@ -513,11 +571,11 @@ impl AtomicInt { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicInt, SeqCst}; + /// use std::sync::atomic::{AtomicInt, Ordering}; /// /// let foo = AtomicInt::new(0b101101); - /// assert_eq!(0b101101, foo.fetch_or(0b110011, SeqCst)); - /// assert_eq!(0b111111, foo.load(SeqCst)); + /// assert_eq!(0b101101, foo.fetch_or(0b110011, Ordering::SeqCst)); + /// assert_eq!(0b111111, foo.load(Ordering::SeqCst)); #[inline] #[stable] pub fn fetch_or(&self, val: int, order: Ordering) -> int { @@ -529,11 +587,11 @@ impl AtomicInt { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicInt, SeqCst}; + /// use std::sync::atomic::{AtomicInt, Ordering}; /// /// let foo = AtomicInt::new(0b101101); - /// assert_eq!(0b101101, foo.fetch_xor(0b110011, SeqCst)); - /// assert_eq!(0b011110, foo.load(SeqCst)); + /// assert_eq!(0b101101, foo.fetch_xor(0b110011, Ordering::SeqCst)); + /// assert_eq!(0b011110, foo.load(Ordering::SeqCst)); #[inline] #[stable] pub fn fetch_xor(&self, val: int, order: Ordering) -> int { @@ -649,11 +707,11 @@ impl AtomicUint { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicUint, SeqCst}; + /// use std::sync::atomic::{AtomicUint, Ordering}; /// /// let foo = AtomicUint::new(0); - /// assert_eq!(0, foo.fetch_add(10, SeqCst)); - /// assert_eq!(10, foo.load(SeqCst)); + /// assert_eq!(0, foo.fetch_add(10, Ordering::SeqCst)); + /// assert_eq!(10, foo.load(Ordering::SeqCst)); /// ``` #[inline] #[stable] @@ -666,11 +724,11 @@ impl AtomicUint { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicUint, SeqCst}; + /// use std::sync::atomic::{AtomicUint, Ordering}; /// /// let foo = AtomicUint::new(10); - /// assert_eq!(10, foo.fetch_sub(10, SeqCst)); - /// assert_eq!(0, foo.load(SeqCst)); + /// assert_eq!(10, foo.fetch_sub(10, Ordering::SeqCst)); + /// assert_eq!(0, foo.load(Ordering::SeqCst)); /// ``` #[inline] #[stable] @@ -683,11 +741,11 @@ impl AtomicUint { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicUint, SeqCst}; + /// use std::sync::atomic::{AtomicUint, Ordering}; /// /// let foo = AtomicUint::new(0b101101); - /// assert_eq!(0b101101, foo.fetch_and(0b110011, SeqCst)); - /// assert_eq!(0b100001, foo.load(SeqCst)); + /// assert_eq!(0b101101, foo.fetch_and(0b110011, Ordering::SeqCst)); + /// assert_eq!(0b100001, foo.load(Ordering::SeqCst)); #[inline] #[stable] pub fn fetch_and(&self, val: uint, order: Ordering) -> uint { @@ -699,11 +757,11 @@ impl AtomicUint { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicUint, SeqCst}; + /// use std::sync::atomic::{AtomicUint, Ordering}; /// /// let foo = AtomicUint::new(0b101101); - /// assert_eq!(0b101101, foo.fetch_or(0b110011, SeqCst)); - /// assert_eq!(0b111111, foo.load(SeqCst)); + /// assert_eq!(0b101101, foo.fetch_or(0b110011, Ordering::SeqCst)); + /// assert_eq!(0b111111, foo.load(Ordering::SeqCst)); #[inline] #[stable] pub fn fetch_or(&self, val: uint, order: Ordering) -> uint { @@ -715,11 +773,11 @@ impl AtomicUint { /// # Examples /// /// ``` - /// use std::sync::atomic::{AtomicUint, SeqCst}; + /// use std::sync::atomic::{AtomicUint, Ordering}; /// /// let foo = AtomicUint::new(0b101101); - /// assert_eq!(0b101101, foo.fetch_xor(0b110011, SeqCst)); - /// assert_eq!(0b011110, foo.load(SeqCst)); + /// assert_eq!(0b101101, foo.fetch_xor(0b110011, Ordering::SeqCst)); + /// assert_eq!(0b011110, foo.load(Ordering::SeqCst)); #[inline] #[stable] pub fn fetch_xor(&self, val: uint, order: Ordering) -> uint { diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 47204dfc422..eb772388dce 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -267,10 +267,6 @@ impl<T> RefCell<T> { unsafe { self.value.into_inner() } } - /// Deprecated, use into_inner() instead - #[deprecated = "renamed to into_inner()"] - pub fn unwrap(self) -> T { self.into_inner() } - /// Attempts to immutably borrow the wrapped value. /// /// The borrow lasts until the returned `Ref` exits scope. Multiple @@ -569,8 +565,4 @@ impl<T> UnsafeCell<T> { #[inline] #[stable] pub unsafe fn into_inner(self) -> T { self.value } - - /// Deprecated, use into_inner() instead - #[deprecated = "renamed to into_inner()"] - pub unsafe fn unwrap(self) -> T { self.into_inner() } } diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 3bd200d38d7..3423e76ea64 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -17,7 +17,6 @@ use iter::Iterator; use mem::transmute; -use ops::FnMut; use option::Option::{None, Some}; use option::Option; use slice::SliceExt; @@ -81,51 +80,6 @@ pub fn from_u32(i: u32) -> Option<char> { } /// -/// Checks if a `char` parses as a numeric digit in the given radix -/// -/// Compared to `is_numeric()`, this function only recognizes the -/// characters `0-9`, `a-z` and `A-Z`. -/// -/// # Return value -/// -/// Returns `true` if `c` is a valid digit under `radix`, and `false` -/// otherwise. -/// -/// # Panics -/// -/// Panics if given a `radix` > 36. -/// -/// # Note -/// -/// This just wraps `to_digit()`. -/// -#[inline] -#[deprecated = "use the Char::is_digit method"] -pub fn is_digit_radix(c: char, radix: uint) -> bool { - c.is_digit(radix) -} - -/// -/// Converts a `char` to the corresponding digit -/// -/// # Return value -/// -/// If `c` is between '0' and '9', the corresponding value -/// between 0 and 9. If `c` is 'a' or 'A', 10. If `c` is -/// 'b' or 'B', 11, etc. Returns none if the `char` does not -/// refer to a digit in the given radix. -/// -/// # Panics -/// -/// Panics if given a `radix` outside the range `[0..36]`. -/// -#[inline] -#[deprecated = "use the Char::to_digit method"] -pub fn to_digit(c: char, radix: uint) -> Option<uint> { - c.to_digit(radix) -} - -/// /// Converts a number to the character representing it /// /// # Return value @@ -156,29 +110,6 @@ pub fn from_digit(num: uint, radix: uint) -> Option<char> { } } -/// Deprecated, call the escape_unicode method instead. -#[deprecated = "use the Char::escape_unicode method"] -pub fn escape_unicode<F>(c: char, mut f: F) where F: FnMut(char) { - for char in c.escape_unicode() { - f(char); - } -} - -/// Deprecated, call the escape_default method instead. -#[deprecated = "use the Char::escape_default method"] -pub fn escape_default<F>(c: char, mut f: F) where F: FnMut(char) { - for c in c.escape_default() { - f(c); - } -} - -/// Returns the amount of bytes this `char` would need if encoded in UTF-8 -#[inline] -#[deprecated = "use the Char::len_utf8 method"] -pub fn len_utf8_bytes(c: char) -> uint { - c.len_utf8() -} - /// Basic `char` manipulations. #[experimental = "trait organization may change"] pub trait Char { @@ -195,22 +126,6 @@ pub trait Char { /// # Panics /// /// Panics if given a radix > 36. - #[deprecated = "use is_digit"] - fn is_digit_radix(self, radix: uint) -> bool; - - /// Checks if a `char` parses as a numeric digit in the given radix. - /// - /// Compared to `is_numeric()`, this function only recognizes the characters - /// `0-9`, `a-z` and `A-Z`. - /// - /// # Return value - /// - /// Returns `true` if `c` is a valid digit under `radix`, and `false` - /// otherwise. - /// - /// # Panics - /// - /// Panics if given a radix > 36. #[unstable = "pending error conventions"] fn is_digit(self, radix: uint) -> bool; @@ -228,23 +143,6 @@ pub trait Char { #[unstable = "pending error conventions, trait organization"] fn to_digit(self, radix: uint) -> Option<uint>; - /// Converts a number to the character representing it. - /// - /// # Return value - /// - /// Returns `Some(char)` if `num` represents one digit under `radix`, - /// using one character of `0-9` or `a-z`, or `None` if it doesn't. - /// - /// # Panics - /// - /// Panics if given a radix > 36. - #[deprecated = "use the char::from_digit free function"] - fn from_digit(num: uint, radix: uint) -> Option<Self>; - - /// Converts from `u32` to a `char` - #[deprecated = "use the char::from_u32 free function"] - fn from_u32(i: u32) -> Option<char>; - /// Returns an iterator that yields the hexadecimal Unicode escape /// of a character, as `char`s. /// @@ -271,11 +169,6 @@ pub trait Char { /// Returns the amount of bytes this character would need if encoded in /// UTF-8. - #[deprecated = "use len_utf8"] - fn len_utf8_bytes(self) -> uint; - - /// Returns the amount of bytes this character would need if encoded in - /// UTF-8. #[unstable = "pending trait organization"] fn len_utf8(self) -> uint; @@ -303,9 +196,6 @@ pub trait Char { #[experimental = "trait is experimental"] impl Char for char { - #[deprecated = "use is_digit"] - fn is_digit_radix(self, radix: uint) -> bool { self.is_digit(radix) } - #[unstable = "pending trait organization"] fn is_digit(self, radix: uint) -> bool { match self.to_digit(radix) { @@ -329,13 +219,6 @@ impl Char for char { else { None } } - #[deprecated = "use the char::from_digit free function"] - fn from_digit(num: uint, radix: uint) -> Option<char> { from_digit(num, radix) } - - #[inline] - #[deprecated = "use the char::from_u32 free function"] - fn from_u32(i: u32) -> Option<char> { from_u32(i) } - #[unstable = "pending error conventions, trait organization"] fn escape_unicode(self) -> EscapeUnicode { EscapeUnicode { c: self, state: EscapeUnicodeState::Backslash } @@ -357,10 +240,6 @@ impl Char for char { } #[inline] - #[deprecated = "use len_utf8"] - fn len_utf8_bytes(self) -> uint { self.len_utf8() } - - #[inline] #[unstable = "pending trait organization"] fn len_utf8(self) -> uint { let code = self as u32; diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 6b52d1817e9..13f9f5ccee9 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -271,16 +271,6 @@ pub trait PartialOrd<Sized? Rhs = Self> for Sized?: PartialEq<Rhs> { } } -/// The equivalence relation. Two values may be equivalent even if they are -/// of different types. The most common use case for this relation is -/// container types; e.g. it is often desirable to be able to use `&str` -/// values to look up entries in a container with `String` keys. -#[deprecated = "Use overloaded core::cmp::PartialEq"] -pub trait Equiv<Sized? T> for Sized? { - /// Implement this function to decide equivalent values. - fn equiv(&self, other: &T) -> bool; -} - /// Compare and return the minimum of two values. #[inline] #[stable] diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index b409b79cbf5..62bfa381c44 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -68,8 +68,6 @@ use option::Option::{Some, None}; use std::kinds::Sized; use uint; -#[deprecated = "renamed to Extend"] pub use self::Extend as Extendable; - /// An interface for dealing with "external iterators". These types of iterators /// can be resumed at any time as all state is stored internally as opposed to /// being located on the call stack. @@ -2781,15 +2779,6 @@ pub struct Repeat<A> { element: A } -impl<A: Clone> Repeat<A> { - /// Create a new `Repeat` that endlessly repeats the element `elt`. - #[inline] - #[deprecated = "use iter::repeat instead"] - pub fn new(elt: A) -> Repeat<A> { - Repeat{element: elt} - } -} - #[unstable = "trait is unstable"] impl<A: Clone> Iterator for Repeat<A> { type Item = A; diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index d8b22a085aa..aab28ae9c47 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -20,7 +20,6 @@ use intrinsics; use mem; use num::Float; use num::FpCategory as Fp; -use num::from_str_radix; use option::Option; #[stable] @@ -314,14 +313,6 @@ impl Float for f32 { unsafe { intrinsics::powf32(self, n) } } - /// sqrt(2.0) - #[inline] - fn sqrt2() -> f32 { consts::SQRT2 } - - /// 1.0 / sqrt(2.0) - #[inline] - fn frac_1_sqrt2() -> f32 { consts::FRAC_1_SQRT2 } - #[inline] fn sqrt(self) -> f32 { if self < 0.0 { @@ -334,66 +325,6 @@ impl Float for f32 { #[inline] fn rsqrt(self) -> f32 { self.sqrt().recip() } - /// Archimedes' constant - #[inline] - fn pi() -> f32 { consts::PI } - - /// 2.0 * pi - #[inline] - fn two_pi() -> f32 { consts::PI_2 } - - /// pi / 2.0 - #[inline] - fn frac_pi_2() -> f32 { consts::FRAC_PI_2 } - - /// pi / 3.0 - #[inline] - fn frac_pi_3() -> f32 { consts::FRAC_PI_3 } - - /// pi / 4.0 - #[inline] - fn frac_pi_4() -> f32 { consts::FRAC_PI_4 } - - /// pi / 6.0 - #[inline] - fn frac_pi_6() -> f32 { consts::FRAC_PI_6 } - - /// pi / 8.0 - #[inline] - fn frac_pi_8() -> f32 { consts::FRAC_PI_8 } - - /// 1.0 / pi - #[inline] - fn frac_1_pi() -> f32 { consts::FRAC_1_PI } - - /// 2.0 / pi - #[inline] - fn frac_2_pi() -> f32 { consts::FRAC_2_PI } - - /// 2.0 / sqrt(pi) - #[inline] - fn frac_2_sqrtpi() -> f32 { consts::FRAC_2_SQRTPI } - - /// Euler's number - #[inline] - fn e() -> f32 { consts::E } - - /// log2(e) - #[inline] - fn log2_e() -> f32 { consts::LOG2_E } - - /// log10(e) - #[inline] - fn log10_e() -> f32 { consts::LOG10_E } - - /// ln(2.0) - #[inline] - fn ln_2() -> f32 { consts::LN_2 } - - /// ln(10.0) - #[inline] - fn ln_10() -> f32 { consts::LN_10 } - /// Returns the exponential of the number. #[inline] fn exp(self) -> f32 { @@ -439,10 +370,3 @@ impl Float for f32 { self * (value / 180.0f32) } } - -#[inline] -#[allow(missing_docs)] -#[deprecated="Use `FromStrRadix::from_str_radix(src, 16)`"] -pub fn from_str_hex(src: &str) -> Option<f32> { - from_str_radix(src, 16) -} diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index a3f5c2df91f..d6d9c3446e9 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -20,7 +20,6 @@ use intrinsics; use mem; use num::Float; use num::FpCategory as Fp; -use num::from_str_radix; use option::Option; // FIXME(#5527): These constants should be deprecated once associated @@ -322,14 +321,6 @@ impl Float for f64 { unsafe { intrinsics::powif64(self, n) } } - /// sqrt(2.0) - #[inline] - fn sqrt2() -> f64 { consts::SQRT2 } - - /// 1.0 / sqrt(2.0) - #[inline] - fn frac_1_sqrt2() -> f64 { consts::FRAC_1_SQRT2 } - #[inline] fn sqrt(self) -> f64 { if self < 0.0 { @@ -342,66 +333,6 @@ impl Float for f64 { #[inline] fn rsqrt(self) -> f64 { self.sqrt().recip() } - /// Archimedes' constant - #[inline] - fn pi() -> f64 { consts::PI } - - /// 2.0 * pi - #[inline] - fn two_pi() -> f64 { consts::PI_2 } - - /// pi / 2.0 - #[inline] - fn frac_pi_2() -> f64 { consts::FRAC_PI_2 } - - /// pi / 3.0 - #[inline] - fn frac_pi_3() -> f64 { consts::FRAC_PI_3 } - - /// pi / 4.0 - #[inline] - fn frac_pi_4() -> f64 { consts::FRAC_PI_4 } - - /// pi / 6.0 - #[inline] - fn frac_pi_6() -> f64 { consts::FRAC_PI_6 } - - /// pi / 8.0 - #[inline] - fn frac_pi_8() -> f64 { consts::FRAC_PI_8 } - - /// 1.0 / pi - #[inline] - fn frac_1_pi() -> f64 { consts::FRAC_1_PI } - - /// 2.0 / pi - #[inline] - fn frac_2_pi() -> f64 { consts::FRAC_2_PI } - - /// 2.0 / sqrt(pi) - #[inline] - fn frac_2_sqrtpi() -> f64 { consts::FRAC_2_SQRTPI } - - /// Euler's number - #[inline] - fn e() -> f64 { consts::E } - - /// log2(e) - #[inline] - fn log2_e() -> f64 { consts::LOG2_E } - - /// log10(e) - #[inline] - fn log10_e() -> f64 { consts::LOG10_E } - - /// ln(2.0) - #[inline] - fn ln_2() -> f64 { consts::LN_2 } - - /// ln(10.0) - #[inline] - fn ln_10() -> f64 { consts::LN_10 } - /// Returns the exponential of the number. #[inline] fn exp(self) -> f64 { @@ -447,10 +378,3 @@ impl Float for f64 { self * (value / 180.0) } } - -#[inline] -#[allow(missing_docs)] -#[deprecated="Use `FromStrRadix::from_str_radix(src, 16)`"] -pub fn from_str_hex(src: &str) -> Option<f64> { - from_str_radix(src, 16) -} diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 4793efbe02a..6c3b153c000 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -15,9 +15,6 @@ #![stable] #![allow(missing_docs)] -use {int, i8, i16, i32, i64}; -use {uint, u8, u16, u32, u64}; -use {f32, f64}; use char::Char; use clone::Clone; use cmp::{PartialEq, Eq}; @@ -30,21 +27,7 @@ use ops::{Add, Sub, Mul, Div, Rem, Neg}; use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr}; use option::Option; use option::Option::{Some, None}; -use str::{FromStr, from_str, StrExt}; - -/// Simultaneous division and remainder -#[inline] -#[deprecated = "use division and remainder directly"] -pub fn div_rem<T: Clone + Div<Output=T> + Rem<Output=T>>(x: T, y: T) -> (T, T) { - (x.clone() / y.clone(), x % y) -} - -/// Raises a `base` to the power of `exp`, using exponentiation by squaring. -#[inline] -#[deprecated = "Use Int::pow() instead, as in 2i.pow(4)"] -pub fn pow<T: Int>(base: T, exp: uint) -> T { - base.pow(exp) -} +use str::{FromStr, StrExt}; /// A built-in signed or unsigned integer. #[unstable = "recently settled as part of numerics reform"] @@ -1345,11 +1328,6 @@ pub trait Float /// Raise a number to a floating point power. fn powf(self, n: Self) -> Self; - /// sqrt(2.0). - fn sqrt2() -> Self; - /// 1.0 / sqrt(2.0). - fn frac_1_sqrt2() -> Self; - /// Take the square root of a number. /// /// Returns NaN if `self` is a negative number. @@ -1357,53 +1335,6 @@ pub trait Float /// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`. fn rsqrt(self) -> Self; - /// Archimedes' constant. - #[deprecated = "use f32::consts or f64::consts instead"] - fn pi() -> Self; - /// 2.0 * pi. - #[deprecated = "use f32::consts or f64::consts instead"] - fn two_pi() -> Self; - /// pi / 2.0. - #[deprecated = "use f32::consts or f64::consts instead"] - fn frac_pi_2() -> Self; - /// pi / 3.0. - #[deprecated = "use f32::consts or f64::consts instead"] - fn frac_pi_3() -> Self; - /// pi / 4.0. - #[deprecated = "use f32::consts or f64::consts instead"] - fn frac_pi_4() -> Self; - /// pi / 6.0. - #[deprecated = "use f32::consts or f64::consts instead"] - fn frac_pi_6() -> Self; - /// pi / 8.0. - #[deprecated = "use f32::consts or f64::consts instead"] - fn frac_pi_8() -> Self; - /// 1.0 / pi. - #[deprecated = "use f32::consts or f64::consts instead"] - fn frac_1_pi() -> Self; - /// 2.0 / pi. - #[deprecated = "use f32::consts or f64::consts instead"] - fn frac_2_pi() -> Self; - /// 2.0 / sqrt(pi). - #[deprecated = "use f32::consts or f64::consts instead"] - fn frac_2_sqrtpi() -> Self; - - /// Euler's number. - #[deprecated = "use f32::consts or f64::consts instead"] - fn e() -> Self; - /// log2(e). - #[deprecated = "use f32::consts or f64::consts instead"] - fn log2_e() -> Self; - /// log10(e). - #[deprecated = "use f32::consts or f64::consts instead"] - fn log10_e() -> Self; - /// ln(2.0). - #[deprecated = "use f32::consts or f64::consts instead"] - fn ln_2() -> Self; - /// ln(10.0). - #[deprecated = "use f32::consts or f64::consts instead"] - fn ln_10() -> Self; - /// Returns `e^(self)`, (the exponential function). fn exp(self) -> Self; /// Returns 2 raised to the power of the number, `2^(self)`. @@ -1609,9 +1540,9 @@ macro_rules! from_str_radix_float_impl { // Parse the exponent as decimal integer let src = src[offset..]; let (is_positive, exp) = match src.slice_shift_char() { - Some(('-', src)) => (false, from_str::<uint>(src)), - Some(('+', src)) => (true, from_str::<uint>(src)), - Some((_, _)) => (true, from_str::<uint>(src)), + Some(('-', src)) => (false, src.parse::<uint>()), + Some(('+', src)) => (true, src.parse::<uint>()), + Some((_, _)) => (true, src.parse::<uint>()), None => return None, }; @@ -1706,135 +1637,3 @@ from_str_radix_int_impl! { u8 } from_str_radix_int_impl! { u16 } from_str_radix_int_impl! { u32 } from_str_radix_int_impl! { u64 } - -// DEPRECATED - -macro_rules! trait_impl { - ($name:ident for $($t:ty)*) => { - $(#[allow(deprecated)] impl $name for $t {})* - }; -} - -#[deprecated = "Generalised numbers are no longer supported"] -#[allow(deprecated)] -pub trait Num: PartialEq + Zero + One - + Neg<Output=Self> - + Add<Output=Self> - + Sub<Output=Self> - + Mul<Output=Self> - + Div<Output=Self> - + Rem<Output=Self> {} -trait_impl! { Num for uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } - -#[deprecated = "Generalised unsigned numbers are no longer supported"] -#[allow(deprecated)] -pub trait Unsigned: Num {} -trait_impl! { Unsigned for uint u8 u16 u32 u64 } - -#[deprecated = "Use `Float` or `Int`"] -#[allow(deprecated)] -pub trait Primitive: Copy + Clone + Num + NumCast + PartialOrd {} -trait_impl! { Primitive for uint u8 u16 u32 u64 int i8 i16 i32 i64 f32 f64 } - -#[deprecated = "The generic `Zero` trait will be removed soon."] -pub trait Zero: Add<Output=Self> { - #[deprecated = "Use `Int::zero()` or `Float::zero()`."] - fn zero() -> Self; - #[deprecated = "Use `x == Int::zero()` or `x == Float::zero()`."] - fn is_zero(&self) -> bool; -} -#[deprecated = "Use `Int::zero()` or `Float::zero()`."] -#[allow(deprecated)] -pub fn zero<T: Zero>() -> T { Zero::zero() } -macro_rules! zero_impl { - ($t:ty, $v:expr) => { - impl Zero for $t { - fn zero() -> $t { $v } - fn is_zero(&self) -> bool { *self == $v } - } - } -} -zero_impl! { uint, 0u } -zero_impl! { u8, 0u8 } -zero_impl! { u16, 0u16 } -zero_impl! { u32, 0u32 } -zero_impl! { u64, 0u64 } -zero_impl! { int, 0i } -zero_impl! { i8, 0i8 } -zero_impl! { i16, 0i16 } -zero_impl! { i32, 0i32 } -zero_impl! { i64, 0i64 } -zero_impl! { f32, 0.0f32 } -zero_impl! { f64, 0.0f64 } - -#[deprecated = "The generic `One` trait will be removed soon."] -pub trait One: Mul<Output=Self> { - #[deprecated = "Use `Int::one()` or `Float::one()`."] - fn one() -> Self; -} -#[deprecated = "Use `Int::one()` or `Float::one()`."] -#[allow(deprecated)] -pub fn one<T: One>() -> T { One::one() } -macro_rules! one_impl { - ($t:ty, $v:expr) => { - impl One for $t { - fn one() -> $t { $v } - } - } -} -one_impl! { uint, 1u } -one_impl! { u8, 1u8 } -one_impl! { u16, 1u16 } -one_impl! { u32, 1u32 } -one_impl! { u64, 1u64 } -one_impl! { int, 1i } -one_impl! { i8, 1i8 } -one_impl! { i16, 1i16 } -one_impl! { i32, 1i32 } -one_impl! { i64, 1i64 } -one_impl! { f32, 1.0f32 } -one_impl! { f64, 1.0f64 } - -#[deprecated = "Use `UnsignedInt::next_power_of_two`"] -pub fn next_power_of_two<T: UnsignedInt>(n: T) -> T { - n.next_power_of_two() -} -#[deprecated = "Use `UnsignedInt::is_power_of_two`"] -pub fn is_power_of_two<T: UnsignedInt>(n: T) -> bool { - n.is_power_of_two() -} -#[deprecated = "Use `UnsignedInt::checked_next_power_of_two`"] -pub fn checked_next_power_of_two<T: UnsignedInt>(n: T) -> Option<T> { - n.checked_next_power_of_two() -} - -#[deprecated = "Generalised bounded values are no longer supported"] -pub trait Bounded { - #[deprecated = "Use `Int::min_value` or `Float::min_value`"] - fn min_value() -> Self; - #[deprecated = "Use `Int::max_value` or `Float::max_value`"] - fn max_value() -> Self; -} -macro_rules! bounded_impl { - ($T:ty, $min:expr, $max:expr) => { - impl Bounded for $T { - #[inline] - fn min_value() -> $T { $min } - - #[inline] - fn max_value() -> $T { $max } - } - }; -} -bounded_impl! { uint, uint::MIN, uint::MAX } -bounded_impl! { u8, u8::MIN, u8::MAX } -bounded_impl! { u16, u16::MIN, u16::MAX } -bounded_impl! { u32, u32::MIN, u32::MAX } -bounded_impl! { u64, u64::MIN, u64::MAX } -bounded_impl! { int, int::MIN, int::MAX } -bounded_impl! { i8, i8::MIN, i8::MAX } -bounded_impl! { i16, i16::MIN, i16::MAX } -bounded_impl! { i32, i32::MIN, i32::MAX } -bounded_impl! { i64, i64::MIN, i64::MAX } -bounded_impl! { f32, f32::MIN_VALUE, f32::MAX_VALUE } -bounded_impl! { f64, f64::MIN_VALUE, f64::MAX_VALUE } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 9aed78d0737..0b77f3456b2 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -94,7 +94,7 @@ use intrinsics; use option::Option::{self, Some, None}; use kinds::{Send, Sized, Sync}; -use cmp::{PartialEq, Eq, Ord, PartialOrd, Equiv}; +use cmp::{PartialEq, Eq, Ord, PartialOrd}; use cmp::Ordering::{self, Less, Equal, Greater}; // FIXME #19649: instrinsic docs don't render, so these have no docs :( @@ -246,22 +246,10 @@ pub unsafe fn write<T>(dst: *mut T, src: T) { pub trait PtrExt: Sized { type Target; - /// Returns the null pointer. - #[deprecated = "call ptr::null instead"] - fn null() -> Self; - /// Returns true if the pointer is null. #[stable] fn is_null(self) -> bool; - /// Returns true if the pointer is not equal to the null pointer. - #[deprecated = "use !p.is_null() instead"] - fn is_not_null(self) -> bool { !self.is_null() } - - /// Returns true if the pointer is not null. - #[deprecated = "use `as uint` instead"] - fn to_uint(self) -> uint; - /// Returns `None` if the pointer is null, or else returns a reference to /// the value wrapped in `Some`. /// @@ -309,18 +297,10 @@ impl<T> PtrExt for *const T { type Target = T; #[inline] - #[deprecated = "call ptr::null instead"] - fn null() -> *const T { null() } - - #[inline] #[stable] fn is_null(self) -> bool { self as uint == 0 } #[inline] - #[deprecated = "use `as uint` instead"] - fn to_uint(self) -> uint { self as uint } - - #[inline] #[stable] unsafe fn offset(self, count: int) -> *const T { intrinsics::offset(self, count) @@ -343,18 +323,10 @@ impl<T> PtrExt for *mut T { type Target = T; #[inline] - #[deprecated = "call ptr::null instead"] - fn null() -> *mut T { null_mut() } - - #[inline] #[stable] fn is_null(self) -> bool { self as uint == 0 } #[inline] - #[deprecated = "use `as uint` instead"] - fn to_uint(self) -> uint { self as uint } - - #[inline] #[stable] unsafe fn offset(self, count: int) -> *mut T { intrinsics::offset(self as *const T, count) as *mut T @@ -415,23 +387,6 @@ impl<T> PartialEq for *mut T { #[stable] impl<T> Eq for *mut T {} -// Equivalence for pointers -#[allow(deprecated)] -#[deprecated = "Use overloaded `core::cmp::PartialEq`"] -impl<T> Equiv<*mut T> for *const T { - fn equiv(&self, other: &*mut T) -> bool { - self.to_uint() == other.to_uint() - } -} - -#[allow(deprecated)] -#[deprecated = "Use overloaded `core::cmp::PartialEq`"] -impl<T> Equiv<*const T> for *mut T { - fn equiv(&self, other: &*const T) -> bool { - self.to_uint() == other.to_uint() - } -} - #[stable] impl<T> Clone for *const T { #[inline] diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index fd4bc4a1413..f17a775cf42 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -36,7 +36,7 @@ use mem::transmute; use clone::Clone; -use cmp::{Ordering, PartialEq, PartialOrd, Eq, Ord, Equiv}; +use cmp::{Ordering, PartialEq, PartialOrd, Eq, Ord}; use cmp::Ordering::{Less, Equal, Greater}; use cmp; use default::Default; @@ -1369,68 +1369,6 @@ pub unsafe fn from_raw_mut_buf<'a, T>(p: &'a *mut T, len: uint) -> &'a mut [T] { // Submodules // -/// Unsafe operations -#[deprecated] -pub mod raw { - use mem::transmute; - use ptr::PtrExt; - use raw::Slice; - use ops::FnOnce; - use option::Option; - use option::Option::{None, Some}; - - /// Form a slice from a pointer and length (as a number of units, - /// not bytes). - #[inline] - #[deprecated = "renamed to slice::from_raw_buf"] - pub unsafe fn buf_as_slice<T, U, F>(p: *const T, len: uint, f: F) -> U where - F: FnOnce(&[T]) -> U, - { - f(transmute(Slice { - data: p, - len: len - })) - } - - /// Form a slice from a pointer and length (as a number of units, - /// not bytes). - #[inline] - #[deprecated = "renamed to slice::from_raw_mut_buf"] - pub unsafe fn mut_buf_as_slice<T, U, F>(p: *mut T, len: uint, f: F) -> U where - F: FnOnce(&mut [T]) -> U, - { - f(transmute(Slice { - data: p as *const T, - len: len - })) - } - - /// Returns a pointer to first element in slice and adjusts - /// slice so it no longer contains that element. Returns None - /// if the slice is empty. O(1). - #[inline] - #[deprecated = "inspect `Slice::{data, len}` manually (increment data by 1)"] - pub unsafe fn shift_ptr<T>(slice: &mut Slice<T>) -> Option<*const T> { - if slice.len == 0 { return None; } - let head: *const T = slice.data; - slice.data = slice.data.offset(1); - slice.len -= 1; - Some(head) - } - - /// Returns a pointer to last element in slice and adjusts - /// slice so it no longer contains that element. Returns None - /// if the slice is empty. O(1). - #[inline] - #[deprecated = "inspect `Slice::{data, len}` manually (decrement len by 1)"] - pub unsafe fn pop_ptr<T>(slice: &mut Slice<T>) -> Option<*const T> { - if slice.len == 0 { return None; } - let tail: *const T = slice.data.offset((slice.len - 1) as int); - slice.len -= 1; - Some(tail) - } -} - /// Operations on `[u8]`. #[experimental = "needs review"] pub mod bytes { @@ -1490,20 +1428,6 @@ impl<A, B> PartialEq<[B]> for [A] where A: PartialEq<B> { #[stable] impl<T: Eq> Eq for [T] {} -#[allow(deprecated)] -#[deprecated = "Use overloaded `core::cmp::PartialEq`"] -impl<T: PartialEq, Sized? V: AsSlice<T>> Equiv<V> for [T] { - #[inline] - fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } -} - -#[allow(deprecated)] -#[deprecated = "Use overloaded `core::cmp::PartialEq`"] -impl<'a,T:PartialEq, Sized? V: AsSlice<T>> Equiv<V> for &'a mut [T] { - #[inline] - fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() } -} - #[stable] impl<T: Ord> Ord for [T] { fn cmp(&self, other: &[T]) -> Ordering { diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 07662c567e3..d069744f8da 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -114,12 +114,6 @@ pub trait FromStr { fn from_str(s: &str) -> Option<Self>; } -/// A utility function that just calls FromStr::from_str -#[deprecated = "call the .parse() method on the string instead"] -pub fn from_str<A: FromStr>(s: &str) -> Option<A> { - FromStr::from_str(s) -} - impl FromStr for bool { /// Parse a `bool` from a string. /// @@ -427,8 +421,7 @@ impl<'a> Fn(&'a u8) -> u8 for BytesDeref { /// An iterator over the substrings of a string, separated by `sep`. #[derive(Clone)] -#[deprecated = "Type is now named `Split` or `SplitTerminator`"] -pub struct CharSplits<'a, Sep> { +struct CharSplits<'a, Sep> { /// The slice remaining to be iterated string: &'a str, sep: Sep, @@ -441,8 +434,7 @@ pub struct CharSplits<'a, Sep> { /// An iterator over the substrings of a string, separated by `sep`, /// splitting at most `count` times. #[derive(Clone)] -#[deprecated = "Type is now named `SplitN` or `RSplitN`"] -pub struct CharSplitsN<'a, Sep> { +struct CharSplitsN<'a, Sep> { iter: CharSplits<'a, Sep>, /// The number of splits remaining count: uint, @@ -873,10 +865,6 @@ pub struct SplitStr<'a> { finished: bool } -/// Deprecated -#[deprecated = "Type is now named `SplitStr`"] -pub type StrSplits<'a> = SplitStr<'a>; - impl<'a> Iterator for MatchIndices<'a> { type Item = (uint, uint); @@ -1027,22 +1015,6 @@ fn run_utf8_validation_iterator(iter: &mut slice::Iter<u8>) } } -/// Determines if a vector of bytes contains valid UTF-8. -#[deprecated = "call from_utf8 instead"] -pub fn is_utf8(v: &[u8]) -> bool { - run_utf8_validation_iterator(&mut v.iter()).is_ok() -} - -/// Deprecated function -#[deprecated = "this function will be removed"] -pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] { - match v.iter().position(|c| *c == 0) { - // don't include the 0 - Some(i) => v[..i], - None => v - } -} - // https://tools.ietf.org/html/rfc3629 static UTF8_CHAR_WIDTH: [u8; 256] = [ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, @@ -1063,13 +1035,6 @@ static UTF8_CHAR_WIDTH: [u8; 256] = [ 4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0, // 0xFF ]; -/// Given a first byte, determine how many bytes are in this UTF-8 character -#[inline] -#[deprecated = "this function has moved to libunicode"] -pub fn utf8_char_width(b: u8) -> uint { - return UTF8_CHAR_WIDTH[b as uint] as uint; -} - /// Struct that contains a `char` and the index of the first byte of /// the next `char` in a string. This can be used as a data structure /// for iterating over the UTF-8 bytes of a string. @@ -1087,78 +1052,19 @@ const CONT_MASK: u8 = 0b0011_1111u8; /// Value of the tag bits (tag mask is !CONT_MASK) of a continuation byte const TAG_CONT_U8: u8 = 0b1000_0000u8; -/// Unsafe operations -#[deprecated] -pub mod raw { - use ptr::PtrExt; - use raw::Slice; - use slice::SliceExt; - use str::StrExt; - - /// Converts a slice of bytes to a string slice without checking - /// that the string contains valid UTF-8. - #[deprecated = "renamed to str::from_utf8_unchecked"] - pub unsafe fn from_utf8<'a>(v: &'a [u8]) -> &'a str { - super::from_utf8_unchecked(v) - } - - /// Form a slice from a C string. Unsafe because the caller must ensure the - /// C string has the static lifetime, or else the return value may be - /// invalidated later. - #[deprecated = "renamed to str::from_c_str"] - pub unsafe fn c_str_to_static_slice(s: *const i8) -> &'static str { - let s = s as *const u8; - let mut curr = s; - let mut len = 0u; - while *curr != 0u8 { - len += 1u; - curr = s.offset(len as int); - } - let v = Slice { data: s, len: len }; - super::from_utf8(::mem::transmute(v)).unwrap() - } - - /// Takes a bytewise (not UTF-8) slice from a string. - /// - /// Returns the substring from [`begin`..`end`). - /// - /// # Panics - /// - /// If begin is greater than end. - /// If end is greater than the length of the string. - #[inline] - #[deprecated = "call the slice_unchecked method instead"] - pub unsafe fn slice_bytes<'a>(s: &'a str, begin: uint, end: uint) -> &'a str { - assert!(begin <= end); - assert!(end <= s.len()); - s.slice_unchecked(begin, end) - } - - /// Takes a bytewise (not UTF-8) slice from a string. - /// - /// Returns the substring from [`begin`..`end`). - /// - /// Caller must check slice boundaries! - #[inline] - #[deprecated = "this has moved to a method on `str` directly"] - pub unsafe fn slice_unchecked<'a>(s: &'a str, begin: uint, end: uint) -> &'a str { - s.slice_unchecked(begin, end) - } -} - /* Section: Trait implementations */ #[allow(missing_docs)] pub mod traits { - use cmp::{Ordering, Ord, PartialEq, PartialOrd, Equiv, Eq}; + use cmp::{Ordering, Ord, PartialEq, PartialOrd, Eq}; use cmp::Ordering::{Less, Equal, Greater}; use iter::IteratorExt; use option::Option; use option::Option::Some; use ops; - use str::{Str, StrExt, eq_slice}; + use str::{StrExt, eq_slice}; #[stable] impl Ord for str { @@ -1197,13 +1103,6 @@ pub mod traits { } } - #[allow(deprecated)] - #[deprecated = "Use overloaded `core::cmp::PartialEq`"] - impl<S: Str> Equiv<S> for str { - #[inline] - fn equiv(&self, other: &S) -> bool { eq_slice(self, other.as_slice()) } - } - impl ops::Slice<uint, str> for str { #[inline] fn as_slice_<'a>(&'a self) -> &'a str { @@ -1236,13 +1135,11 @@ pub trait Str for Sized? { fn as_slice<'a>(&'a self) -> &'a str; } -#[allow(deprecated)] impl Str for str { #[inline] fn as_slice<'a>(&'a self) -> &'a str { self } } -#[allow(deprecated)] impl<'a, Sized? S> Str for &'a S where S: Str { #[inline] fn as_slice(&self) -> &str { Str::as_slice(*self) } @@ -1316,6 +1213,7 @@ pub trait StrExt for Sized? { fn as_ptr(&self) -> *const u8; fn len(&self) -> uint; fn is_empty(&self) -> bool; + fn parse<T: FromStr>(&self) -> Option<T>; } #[inline(never)] @@ -1352,7 +1250,6 @@ impl StrExt for str { } #[inline] - #[allow(deprecated)] // For using CharSplits fn split<P: CharEq>(&self, pat: P) -> Split<P> { Split(CharSplits { string: self, @@ -1364,7 +1261,6 @@ impl StrExt for str { } #[inline] - #[allow(deprecated)] // For using CharSplitsN fn splitn<P: CharEq>(&self, count: uint, pat: P) -> SplitN<P> { SplitN(CharSplitsN { iter: self.split(pat).0, @@ -1374,7 +1270,6 @@ impl StrExt for str { } #[inline] - #[allow(deprecated)] // For using CharSplits fn split_terminator<P: CharEq>(&self, pat: P) -> SplitTerminator<P> { SplitTerminator(CharSplits { allow_trailing_empty: false, @@ -1383,7 +1278,6 @@ impl StrExt for str { } #[inline] - #[allow(deprecated)] // For using CharSplitsN fn rsplitn<P: CharEq>(&self, count: uint, pat: P) -> RSplitN<P> { RSplitN(CharSplitsN { iter: self.split(pat).0, @@ -1681,6 +1575,9 @@ impl StrExt for str { #[inline] fn is_empty(&self) -> bool { self.len() == 0 } + + #[inline] + fn parse<T: FromStr>(&self) -> Option<T> { FromStr::from_str(self) } } #[stable] diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index ad2323296d9..4aca830cb94 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -58,44 +58,6 @@ macro_rules! tuple_impls { } )+) => { $( - #[allow(missing_docs)] - #[deprecated] - pub trait $Tuple<$($T),+> { - $( - #[deprecated = "use tuple indexing: `tuple.N`"] - fn $valN(self) -> $T; - #[deprecated = "use tuple indexing: `&tuple.N`"] - fn $refN<'a>(&'a self) -> &'a $T; - #[deprecated = "use tuple indexing: `&mut tuple.N`"] - fn $mutN<'a>(&'a mut self) -> &'a mut $T; - )+ - } - - impl<$($T),+> $Tuple<$($T),+> for ($($T,)+) { - $( - #[inline] - #[allow(unused_variables)] - #[deprecated = "use tuple indexing: `tuple.N`"] - fn $valN(self) -> $T { - e!(self.$idx) - } - - #[inline] - #[allow(unused_variables)] - #[deprecated = "use tuple indexing: `&tuple.N`"] - fn $refN<'a>(&'a self) -> &'a $T { - e!(&self.$idx) - } - - #[inline] - #[allow(unused_variables)] - #[deprecated = "use tuple indexing: &mut tuple.N"] - fn $mutN<'a>(&'a mut self) -> &'a mut $T { - e!(&mut self.$idx) - } - )+ - } - #[stable] impl<$($T:Clone),+> Clone for ($($T,)+) { fn clone(&self) -> ($($T,)+) { |
