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/libcore | |
| parent | fb169d5543c84e11038ba2d07b538ec88fb49ca6 (diff) | |
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/libcore')
| -rw-r--r-- | src/libcore/any.rs | 19 | ||||
| -rw-r--r-- | src/libcore/cmp.rs | 14 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 21 | ||||
| -rw-r--r-- | src/libcore/kinds.rs | 3 | ||||
| -rw-r--r-- | src/libcore/lib.rs | 7 | ||||
| -rw-r--r-- | src/libcore/mem.rs | 146 | ||||
| -rw-r--r-- | src/libcore/option.rs | 140 | ||||
| -rw-r--r-- | src/libcore/ptr.rs | 64 | ||||
| -rw-r--r-- | src/libcore/result.rs | 40 | ||||
| -rw-r--r-- | src/libcore/slice.rs | 285 |
10 files changed, 8 insertions, 731 deletions
diff --git a/src/libcore/any.rs b/src/libcore/any.rs index c4b07d42e69..021f575b0ac 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -76,11 +76,6 @@ use option::{Option, Some, None}; use raw::TraitObject; use intrinsics::TypeId; -/// A type with no inhabitants -#[deprecated = "this type is being removed, define a type locally if \ - necessary"] -pub enum Void { } - /////////////////////////////////////////////////////////////////////////////// // Any trait /////////////////////////////////////////////////////////////////////////////// @@ -117,13 +112,6 @@ pub trait AnyRefExt<'a> { /// `None` if it isn't. #[unstable = "naming conventions around acquiring references may change"] fn downcast_ref<T: 'static>(self) -> Option<&'a T>; - - /// Returns some reference to the boxed value if it is of type `T`, or - /// `None` if it isn't. - #[deprecated = "this function has been renamed to `downcast_ref`"] - fn as_ref<T: 'static>(self) -> Option<&'a T> { - self.downcast_ref::<T>() - } } #[stable] @@ -166,13 +154,6 @@ pub trait AnyMutRefExt<'a> { /// `None` if it isn't. #[unstable = "naming conventions around acquiring references may change"] fn downcast_mut<T: 'static>(self) -> Option<&'a mut T>; - - /// Returns some mutable reference to the boxed value if it is of type `T`, or - /// `None` if it isn't. - #[deprecated = "this function has been renamed to `downcast_mut`"] - fn as_mut<T: 'static>(self) -> Option<&'a mut T> { - self.downcast_mut::<T>() - } } #[stable] diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 9542b28e981..505dc183480 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -178,20 +178,6 @@ impl PartialOrd for Ordering { } } -/// Combine orderings, lexically. -/// -/// For example for a type `(int, int)`, two comparisons could be done. -/// If the first ordering is different, the first ordering is all that must be returned. -/// If the first ordering is equal, then second ordering is returned. -#[inline] -#[deprecated = "Just call .cmp() on a tuple"] -pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering { - match o1 { - Equal => o2, - _ => o1 - } -} - /// Trait for values that can be compared for a sort-order. /// /// PartialOrd only requires implementation of the `partial_cmp` method, diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 4b970dc3d25..e2a4fdfe79b 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -428,27 +428,6 @@ pub trait Iterator<A> { ByRef{iter: self} } - /// Apply a function to each element, or stop iterating if the - /// function returns `false`. - /// - /// # Example - /// - /// ```rust,ignore - /// range(0u, 5).advance(|x| {print!("{} ", x); true}); - /// ``` - #[deprecated = "use the `all` method instead"] - #[inline] - fn advance(&mut self, f: |A| -> bool) -> bool { - loop { - match self.next() { - Some(x) => { - if !f(x) { return false; } - } - None => { return true; } - } - } - } - /// Loops through the entire iterator, collecting all of the elements into /// a container implementing `FromIterator`. /// diff --git a/src/libcore/kinds.rs b/src/libcore/kinds.rs index b0206e73e47..677bc91d9dd 100644 --- a/src/libcore/kinds.rs +++ b/src/libcore/kinds.rs @@ -20,9 +20,6 @@ by the compiler automatically for the types to which they apply. */ -#[deprecated = "This has been renamed to Sync"] -pub use self::Sync as Share; - /// Types able to be transferred across task boundaries. #[lang="send"] pub trait Send for Sized? { diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 8134f521024..62a4fbd2e08 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -104,13 +104,6 @@ pub mod clone; pub mod default; pub mod collections; -#[deprecated = "all functionality now lives in `std::cell`"] -/// Deprecated module in favor of `std::cell` -pub mod ty { - #[deprecated = "this type has been renamed to `UnsafeCell`"] - pub use cell::UnsafeCell as Unsafe; -} - /* Core types and methods on primitives */ pub mod any; diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 947fa2ec92e..97b3554b1e1 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -14,7 +14,6 @@ //! types, initializing and manipulating memory. use intrinsics; -use num::Int; use ptr; pub use intrinsics::transmute; @@ -43,26 +42,6 @@ pub fn size_of_val<T>(_val: &T) -> uint { size_of::<T>() } -/// Deprecated, this function will be removed soon -#[inline] -#[deprecated = "this function will be removed soon"] -pub fn nonzero_size_of<T>() -> uint { - match size_of::<T>() { - 0 => 1, - n => n, - } -} - -/// Deprecated, this function will be removed soon -#[inline] -#[deprecated = "this function will be removed soon"] -pub fn nonzero_size_of_val<T>(val: &T) -> uint { - match size_of_val::<T>(val) { - 0 => 1, - n => n, - } -} - /// Returns the ABI-required minimum alignment of a type /// /// This is the alignment used for struct fields. It may be smaller @@ -107,16 +86,6 @@ pub fn align_of_val<T>(_val: &T) -> uint { align_of::<T>() } -/// Deprecated, this function has been renamed to align_of -#[inline] -#[deprecated = "use mem::align_of instead"] -pub fn pref_align_of<T>() -> uint { align_of::<T>() } - -/// Deprecated, this function has been renamed to align_of_val -#[inline] -#[deprecated = "use mem::align_of_val instead"] -pub fn pref_align_of_val<T>(val: &T) -> uint { align_of_val(val) } - /// Create a value initialized to zero. /// /// This function is similar to allocating space for a a local variable and @@ -134,11 +103,6 @@ pub unsafe fn zeroed<T>() -> T { intrinsics::init() } -/// Deprecated, use zeroed() instead -#[inline] -#[deprecated = "this function has been renamed to zeroed()"] -pub unsafe fn init<T>() -> T { zeroed() } - /// Create an uninitialized value. /// /// Care must be taken when using this function, if the type `T` has a @@ -153,116 +117,6 @@ pub unsafe fn uninitialized<T>() -> T { intrinsics::uninit() } -/// Deprecated, use `uninitialized` instead. -#[inline] -#[deprecated = "this function has been renamed to `uninitialized`"] -pub unsafe fn uninit<T>() -> T { - intrinsics::uninit() -} - -/// Unsafely overwrite a memory location with the given value without destroying -/// the old value. -/// -/// This operation is unsafe because it does not destroy the previous value -/// contained at the location `dst`. This could leak allocations or resources, -/// so care must be taken to previously deallocate the value at `dst`. -#[inline] -#[deprecated = "use ptr::write"] -pub unsafe fn overwrite<T>(dst: *mut T, src: T) { - intrinsics::move_val_init(&mut *dst, src) -} - -/// Deprecated, use `overwrite` instead -#[inline] -#[deprecated = "this function has been renamed to overwrite()"] -pub unsafe fn move_val_init<T>(dst: &mut T, src: T) { - ptr::write(dst, src) -} - -/// Convert an u16 to little endian from the target's endianness. -/// -/// On little endian, this is a no-op. On big endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::to_le` instead"] -pub fn to_le16(x: u16) -> u16 { x.to_le() } - -/// Convert an u32 to little endian from the target's endianness. -/// -/// On little endian, this is a no-op. On big endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::to_le` instead"] -pub fn to_le32(x: u32) -> u32 { x.to_le() } - -/// Convert an u64 to little endian from the target's endianness. -/// -/// On little endian, this is a no-op. On big endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::to_le` instead"] -pub fn to_le64(x: u64) -> u64 { x.to_le() } - -/// Convert an u16 to big endian from the target's endianness. -/// -/// On big endian, this is a no-op. On little endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::to_be` instead"] -pub fn to_be16(x: u16) -> u16 { x.to_be() } - -/// Convert an u32 to big endian from the target's endianness. -/// -/// On big endian, this is a no-op. On little endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::to_be` instead"] -pub fn to_be32(x: u32) -> u32 { x.to_be() } - -/// Convert an u64 to big endian from the target's endianness. -/// -/// On big endian, this is a no-op. On little endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::to_be` instead"] -pub fn to_be64(x: u64) -> u64 { x.to_be() } - -/// Convert an u16 from little endian to the target's endianness. -/// -/// On little endian, this is a no-op. On big endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::from_le` instead"] -pub fn from_le16(x: u16) -> u16 { Int::from_le(x) } - -/// Convert an u32 from little endian to the target's endianness. -/// -/// On little endian, this is a no-op. On big endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::from_le` instead"] -pub fn from_le32(x: u32) -> u32 { Int::from_le(x) } - -/// Convert an u64 from little endian to the target's endianness. -/// -/// On little endian, this is a no-op. On big endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::from_le` instead"] -pub fn from_le64(x: u64) -> u64 { Int::from_le(x) } - -/// Convert an u16 from big endian to the target's endianness. -/// -/// On big endian, this is a no-op. On little endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::from_be` instead"] -pub fn from_be16(x: u16) -> u16 { Int::from_be(x) } - -/// Convert an u32 from big endian to the target's endianness. -/// -/// On big endian, this is a no-op. On little endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::from_be` instead"] -pub fn from_be32(x: u32) -> u32 { Int::from_be(x) } - -/// Convert an u64 from big endian to the target's endianness. -/// -/// On big endian, this is a no-op. On little endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::from_be` instead"] -pub fn from_be64(x: u64) -> u64 { Int::from_be(x) } - /// Swap the values at two mutable locations of the same type, without /// deinitialising or copying either one. #[inline] diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 9b66f900d9c..5b34cab611a 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -482,33 +482,6 @@ impl<T> Option<T> { } } - /// Deprecated. - /// - /// Applies a function to the contained value or does nothing. - /// Returns true if the contained value was mutated. - #[deprecated = "removed due to lack of use"] - pub fn mutate(&mut self, f: |T| -> T) -> bool { - if self.is_some() { - *self = Some(f(self.take().unwrap())); - true - } else { false } - } - - /// Deprecated. - /// - /// Applies a function to the contained value or sets it to a default. - /// Returns true if the contained value was mutated, or false if set to the default. - #[deprecated = "removed due to lack of use"] - pub fn mutate_or_set(&mut self, def: T, f: |T| -> T) -> bool { - if self.is_some() { - *self = Some(f(self.take().unwrap())); - true - } else { - *self = Some(def); - false - } - } - ///////////////////////////////////////////////////////////////////////// // Iterator constructors ///////////////////////////////////////////////////////////////////////// @@ -530,12 +503,6 @@ impl<T> Option<T> { Item{opt: self.as_ref()} } - /// Deprecated: use `iter_mut` - #[deprecated = "use iter_mut"] - pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> { - self.iter_mut() - } - /// Returns a mutable iterator over the possibly contained value. /// /// # Example @@ -557,12 +524,6 @@ impl<T> Option<T> { Item{opt: self.as_mut()} } - /// Deprecated: use `into_iter`. - #[deprecated = "use into_iter"] - pub fn move_iter(self) -> Item<T> { - self.into_iter() - } - /// Returns a consuming iterator over the possibly contained value. /// /// # Example @@ -713,100 +674,6 @@ impl<T> Option<T> { pub fn take(&mut self) -> Option<T> { mem::replace(self, None) } - - /// Deprecated. - /// - /// Filters an optional value using a given function. - #[inline(always)] - #[deprecated = "removed due to lack of use"] - pub fn filtered(self, f: |t: &T| -> bool) -> Option<T> { - match self { - Some(x) => if f(&x) { Some(x) } else { None }, - None => None - } - } - - /// Deprecated. - /// - /// Applies a function zero or more times until the result is `None`. - #[inline] - #[deprecated = "removed due to lack of use"] - pub fn while_some(self, f: |v: T| -> Option<T>) { - let mut opt = self; - loop { - match opt { - Some(x) => opt = f(x), - None => break - } - } - } - - ///////////////////////////////////////////////////////////////////////// - // Common special cases - ///////////////////////////////////////////////////////////////////////// - - /// Deprecated: use `take().unwrap()` instead. - /// - /// The option dance. Moves a value out of an option type and returns it, - /// replacing the original with `None`. - /// - /// # Failure - /// - /// Fails if the value equals `None`. - #[inline] - #[deprecated = "use take().unwrap() instead"] - pub fn take_unwrap(&mut self) -> T { - match self.take() { - Some(x) => x, - None => fail!("called `Option::take_unwrap()` on a `None` value") - } - } - - /// Deprecated: use `as_ref().unwrap()` instead. - /// - /// Gets an immutable reference to the value inside an option. - /// - /// # Failure - /// - /// Fails if the value equals `None` - /// - /// # Safety note - /// - /// In general, because this function may fail, its use is discouraged - /// (calling `get` on `None` is akin to dereferencing a null pointer). - /// Instead, prefer to use pattern matching and handle the `None` - /// case explicitly. - #[inline] - #[deprecated = "use .as_ref().unwrap() instead"] - pub fn get_ref<'a>(&'a self) -> &'a T { - match *self { - Some(ref x) => x, - None => fail!("called `Option::get_ref()` on a `None` value"), - } - } - - /// Deprecated: use `as_mut().unwrap()` instead. - /// - /// Gets a mutable reference to the value inside an option. - /// - /// # Failure - /// - /// Fails if the value equals `None` - /// - /// # Safety note - /// - /// In general, because this function may fail, its use is discouraged - /// (calling `get` on `None` is akin to dereferencing a null pointer). - /// Instead, prefer to use pattern matching and handle the `None` - /// case explicitly. - #[inline] - #[deprecated = "use .as_mut().unwrap() instead"] - pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T { - match *self { - Some(ref mut x) => x, - None => fail!("called `Option::get_mut_ref()` on a `None` value"), - } - } } impl<T: Default> Option<T> { @@ -908,13 +775,6 @@ impl<A> ExactSize<A> for Item<A> {} // Free functions ///////////////////////////////////////////////////////////////////////////// -/// Deprecated: use `Iterator::collect` instead. -#[inline] -#[deprecated = "use Iterator::collect instead"] -pub fn collect<T, Iter: Iterator<Option<T>>, V: FromIterator<T>>(mut iter: Iter) -> Option<V> { - iter.collect() -} - impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> { /// Takes each element in the `Iterator`: if it is `None`, no further /// elements are taken, and the `None` is returned. Should no `None` occur, a diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index b76c92140fd..f0cd8402b14 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -90,7 +90,6 @@ use mem; use clone::Clone; use intrinsics; -use iter::range; use option::{Some, None, Option}; use cmp::{PartialEq, Eq, PartialOrd, Equiv, Ordering, Less, Equal, Greater}; @@ -113,10 +112,6 @@ pub use intrinsics::set_memory; #[unstable = "may need a different name after pending changes to pointer types"] pub fn null<T>() -> *const T { 0 as *const T } -/// Deprecated: use `null_mut`. -#[deprecated = "use null_mut"] -pub fn mut_null<T>() -> *mut T { null_mut() } - /// Create an unsafe mutable null pointer. /// /// # Example @@ -203,59 +198,6 @@ pub unsafe fn write<T>(dst: *mut T, src: T) { intrinsics::move_val_init(&mut *dst, src) } -/// Given a *const *const T (pointer to an array of pointers), -/// iterate through each *const T, up to the provided `len`, -/// passing to the provided callback function -#[deprecated = "old-style iteration. use a loop and RawPtr::offset"] -pub unsafe fn array_each_with_len<T>(arr: *const *const T, len: uint, - cb: |*const T|) { - if arr.is_null() { - fail!("ptr::array_each_with_len failure: arr input is null pointer"); - } - //let start_ptr = *arr; - for e in range(0, len) { - let n = arr.offset(e as int); - cb(*n); - } -} - -/// Given a null-pointer-terminated *const *const T (pointer to -/// an array of pointers), iterate through each *const T, -/// passing to the provided callback function -/// -/// # Safety Note -/// -/// This will only work with a null-terminated -/// pointer array. -#[deprecated = "old-style iteration. use a loop and RawPtr::offset"] -#[allow(deprecated)] -pub unsafe fn array_each<T>(arr: *const *const T, cb: |*const T|) { - if arr.is_null() { - fail!("ptr::array_each_with_len failure: arr input is null pointer"); - } - let len = buf_len(arr); - array_each_with_len(arr, len, cb); -} - -/// Return the offset of the first null pointer in `buf`. -#[inline] -#[deprecated = "use a loop and RawPtr::offset"] -#[allow(deprecated)] -pub unsafe fn buf_len<T>(buf: *const *const T) -> uint { - position(buf, |i| *i == null()) -} - -/// Return the first offset `i` such that `f(buf[i]) == true`. -#[inline] -#[deprecated = "old-style iteration. use a loop and RawPtr::offset"] -pub unsafe fn position<T>(buf: *const T, f: |&T| -> bool) -> uint { - let mut i = 0; - loop { - if f(&(*buf.offset(i as int))) { return i; } - else { i += 1; } - } -} - /// Methods on raw pointers pub trait RawPtr<T> { /// Returns the null pointer. @@ -280,12 +222,6 @@ pub trait RawPtr<T> { /// the returned value could be pointing to invalid memory. unsafe fn as_ref<'a>(&self) -> Option<&'a T>; - /// A synonym for `as_ref`, except with incorrect lifetime semantics - #[deprecated="Use `as_ref` instead"] - unsafe fn to_option<'a>(&'a self) -> Option<&'a T> { - mem::transmute(self.as_ref()) - } - /// Calculates the offset from a pointer. The offset *must* be in-bounds of /// the object, or one-byte-past-the-end. `count` is in units of T; e.g. a /// `count` of 3 represents a pointer offset of `3 * sizeof::<T>()` bytes. diff --git a/src/libcore/result.rs b/src/libcore/result.rs index caede952e2f..27bb649d1d9 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -566,12 +566,6 @@ impl<T, E> Result<T, E> { Item{opt: self.as_ref().ok()} } - /// Deprecated: use `iter_mut`. - #[deprecated = "use iter_mut"] - pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> { - self.iter_mut() - } - /// Returns a mutable iterator over the possibly contained value. /// /// # Example @@ -593,12 +587,6 @@ impl<T, E> Result<T, E> { Item{opt: self.as_mut().ok()} } - /// Deprecated: `use into_iter`. - #[deprecated = "use into_iter"] - pub fn move_iter(self) -> Item<T> { - self.into_iter() - } - /// Returns a consuming iterator over the possibly contained value. /// /// # Example @@ -771,13 +759,6 @@ impl<T, E> Result<T, E> { Err(e) => op(e) } } - - /// Deprecated name for `unwrap_or_else()`. - #[deprecated = "replaced by .unwrap_or_else()"] - #[inline] - pub fn unwrap_or_handle(self, op: |E| -> T) -> T { - self.unwrap_or_else(op) - } } impl<T, E: Show> Result<T, E> { @@ -902,14 +883,6 @@ impl<A> ExactSize<A> for Item<A> {} // Free functions ///////////////////////////////////////////////////////////////////////////// -/// Deprecated: use `Iterator::collect`. -#[inline] -#[deprecated = "use Iterator::collect instead"] -pub fn collect<T, E, Iter: Iterator<Result<T, E>>, V: FromIterator<T>>(mut iter: Iter) - -> Result<V, E> { - iter.collect() -} - impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> { /// Takes each element in the `Iterator`: if it is an `Err`, no further /// elements are taken, and the `Err` is returned. Should no `Err` occur, a @@ -984,16 +957,3 @@ pub fn fold<T, } Ok(init) } - -/// Deprecated. -/// -/// Perform a trivial fold operation over the result values -/// from an iterator. -/// -/// If an `Err` is encountered, it is immediately returned. -/// Otherwise, a simple `Ok(())` is returned. -#[inline] -#[deprecated = "use fold instead"] -pub fn fold_<T,E,Iter:Iterator<Result<T,E>>>(iterator: Iter) -> Result<(),E> { - fold(iterator, (), |_, _| ()) -} diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 5847a6177d7..6b24592b17f 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -176,29 +176,16 @@ pub trait ImmutableSlice<'a, T> { #[unstable = "name may change"] fn tail(&self) -> &'a [T]; - /// Returns all but the first `n' elements of a slice. - #[deprecated = "use slice_from"] - fn tailn(&self, n: uint) -> &'a [T]; - /// Returns all but the last element of a slice. #[unstable = "name may change"] fn init(&self) -> &'a [T]; - /// Returns all but the last `n' elements of a slice. - #[deprecated = "use slice_to but note the arguments are different"] - fn initn(&self, n: uint) -> &'a [T]; - /// Returns the last element of a slice, or `None` if it is empty. #[unstable = "name may change"] fn last(&self) -> Option<&'a T>; /// Returns a pointer to the element at the given index, without doing /// bounds checking. - #[deprecated = "renamed to `unsafe_get`"] - unsafe fn unsafe_ref(self, index: uint) -> &'a T; - - /// Returns a pointer to the element at the given index, without doing - /// bounds checking. #[unstable] unsafe fn unsafe_get(self, index: uint) -> &'a T; @@ -212,10 +199,6 @@ pub trait ImmutableSlice<'a, T> { #[unstable] fn as_ptr(&self) -> *const T; - /// Deprecated: use `binary_search`. - #[deprecated = "use binary_search"] - fn bsearch(&self, f: |&T| -> Ordering) -> Option<uint>; - /// Binary search a sorted slice with a comparator function. /// /// The comparator function should implement an order consistent @@ -251,44 +234,6 @@ pub trait ImmutableSlice<'a, T> { /// ``` #[unstable = "waiting on unboxed closures"] fn binary_search(&self, f: |&T| -> Ordering) -> BinarySearchResult; - - /** - * Returns an immutable reference to the first element in this slice - * and adjusts the slice in place so that it no longer contains - * that element. O(1). - * - * Equivalent to: - * - * ```ignore - * if self.len() == 0 { return None } - * let head = &self[0]; - * *self = self[1..]; - * Some(head) - * ``` - * - * Returns `None` if vector is empty - */ - #[deprecated = "find some other way. sorry"] - fn shift_ref(&mut self) -> Option<&'a T>; - - /** - * Returns an immutable reference to the last element in this slice - * and adjusts the slice in place so that it no longer contains - * that element. O(1). - * - * Equivalent to: - * - * ```ignore - * if self.len() == 0 { return None; } - * let tail = &self[self.len() - 1]; - * *self = self[..self.len() - 1]; - * Some(tail) - * ``` - * - * Returns `None` if slice is empty. - */ - #[deprecated = "find some other way. sorry"] - fn pop_ref(&mut self) -> Option<&'a T>; } #[unstable] @@ -389,32 +334,16 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] { fn tail(&self) -> &'a [T] { (*self)[1..] } #[inline] - #[deprecated = "use slice_from"] - fn tailn(&self, n: uint) -> &'a [T] { (*self)[n..] } - - #[inline] fn init(&self) -> &'a [T] { (*self)[..self.len() - 1] } #[inline] - #[deprecated = "use slice_to but note the arguments are different"] - fn initn(&self, n: uint) -> &'a [T] { - (*self)[..self.len() - n] - } - - #[inline] fn last(&self) -> Option<&'a T> { if self.len() == 0 { None } else { Some(&self[self.len() - 1]) } } #[inline] - #[deprecated = "renamed to `unsafe_get`"] - unsafe fn unsafe_ref(self, index: uint) -> &'a T { - transmute(self.repr().data.offset(index as int)) - } - - #[inline] unsafe fn unsafe_get(self, index: uint) -> &'a T { transmute(self.repr().data.offset(index as int)) } @@ -424,27 +353,6 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] { self.repr().data } - - #[deprecated = "use binary_search"] - fn bsearch(&self, f: |&T| -> Ordering) -> Option<uint> { - let mut base : uint = 0; - let mut lim : uint = self.len(); - - while lim != 0 { - let ix = base + (lim >> 1); - match f(&self[ix]) { - Equal => return Some(ix), - Less => { - base = ix + 1; - lim -= 1; - } - Greater => () - } - lim >>= 1; - } - return None; - } - #[unstable] fn binary_search(&self, f: |&T| -> Ordering) -> BinarySearchResult { let mut base : uint = 0; @@ -464,26 +372,6 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] { } return NotFound(base); } - - fn shift_ref(&mut self) -> Option<&'a T> { - unsafe { - let s: &mut RawSlice<T> = transmute(self); - match raw::shift_ptr(s) { - Some(p) => Some(&*p), - None => None - } - } - } - - fn pop_ref(&mut self) -> Option<&'a T> { - unsafe { - let s: &mut RawSlice<T> = transmute(self); - match raw::pop_ptr(s) { - Some(p) => Some(&*p), - None => None - } - } - } } @@ -557,12 +445,6 @@ pub trait MutableSlice<'a, T> { /// Primarily intended for getting a &mut [T] from a [T, ..N]. fn as_mut_slice(self) -> &'a mut [T]; - /// Deprecated: use `slice_mut`. - #[deprecated = "use slice_mut"] - fn mut_slice(self, start: uint, end: uint) -> &'a mut [T] { - self.slice_mut(start, end) - } - /// Returns a mutable subslice spanning the interval [`start`, `end`). /// /// Fails when the end of the new slice lies beyond the end of the @@ -572,12 +454,6 @@ pub trait MutableSlice<'a, T> { #[unstable = "waiting on final error conventions"] fn slice_mut(self, start: uint, end: uint) -> &'a mut [T]; - /// Deprecated: use `slice_from_mut`. - #[deprecated = "use slice_from_mut"] - fn mut_slice_from(self, start: uint) -> &'a mut [T] { - self.slice_from_mut(start) - } - /// Returns a mutable subslice from `start` to the end of the slice. /// /// Fails when `start` is strictly greater than the length of the original slice. @@ -586,12 +462,6 @@ pub trait MutableSlice<'a, T> { #[unstable = "waiting on final error conventions"] fn slice_from_mut(self, start: uint) -> &'a mut [T]; - /// Deprecated: use `slice_to_mut`. - #[deprecated = "use slice_to_mut"] - fn mut_slice_to(self, end: uint) -> &'a mut [T] { - self.slice_to_mut(end) - } - /// Returns a mutable subslice from the start of the slice to `end`. /// /// Fails when `end` is strictly greater than the length of the original slice. @@ -600,12 +470,6 @@ pub trait MutableSlice<'a, T> { #[unstable = "waiting on final error conventions"] fn slice_to_mut(self, end: uint) -> &'a mut [T]; - /// Deprecated: use `iter_mut`. - #[deprecated = "use iter_mut"] - fn mut_iter(self) -> MutItems<'a, T> { - self.iter_mut() - } - /// Returns an iterator that allows modifying each value #[unstable = "waiting on iterator type name conventions"] fn iter_mut(self) -> MutItems<'a, T>; @@ -622,22 +486,10 @@ pub trait MutableSlice<'a, T> { #[unstable = "name may change"] fn init_mut(self) -> &'a mut [T]; - /// Deprecated: use `last_mut`. - #[deprecated = "use last_mut"] - fn mut_last(self) -> Option<&'a mut T> { - self.last_mut() - } - /// Returns a mutable pointer to the last item in the slice. #[unstable = "name may change"] fn last_mut(self) -> Option<&'a mut T>; - /// Deprecated: use `split_mut`. - #[deprecated = "use split_mut"] - fn mut_split(self, pred: |&T|: 'a -> bool) -> MutSplits<'a, T> { - self.split_mut(pred) - } - /// Returns an iterator over mutable subslices separated by elements that /// match `pred`. The matched element is not contained in the subslices. #[unstable = "waiting on unboxed closures, iterator type name conventions"] @@ -656,12 +508,6 @@ pub trait MutableSlice<'a, T> { #[unstable = "waiting on unboxed closures, iterator type name conventions"] fn rsplitn_mut(self, n: uint, pred: |&T|: 'a -> bool) -> SplitsN<MutSplits<'a, T>>; - /// Deprecated: use `chunks_mut`. - #[deprecated = "use chunks_mut"] - fn mut_chunks(self, chunk_size: uint) -> MutChunks<'a, T> { - self.chunks_mut(chunk_size) - } - /// Returns an iterator over `chunk_size` elements of the slice at a time. /// The chunks are mutable and do not overlap. If `chunk_size` does /// not divide the length of the slice, then the last chunk will not @@ -673,44 +519,6 @@ pub trait MutableSlice<'a, T> { #[unstable = "waiting on iterator type name conventions"] fn chunks_mut(self, chunk_size: uint) -> MutChunks<'a, T>; - /** - * Returns a mutable reference to the first element in this slice - * and adjusts the slice in place so that it no longer contains - * that element. O(1). - * - * Equivalent to: - * - * ```ignore - * if self.len() == 0 { return None; } - * let head = &mut self[0]; - * *self = self[mut 1..]; - * Some(head) - * ``` - * - * Returns `None` if slice is empty - */ - #[deprecated = "use iter_mut"] - fn mut_shift_ref(&mut self) -> Option<&'a mut T>; - - /** - * Returns a mutable reference to the last element in this slice - * and adjusts the slice in place so that it no longer contains - * that element. O(1). - * - * Equivalent to: - * - * ```ignore - * if self.len() == 0 { return None; } - * let tail = &mut self[self.len() - 1]; - * *self = self[mut ..self.len() - 1]; - * Some(tail) - * ``` - * - * Returns `None` if slice is empty. - */ - #[deprecated = "use iter_mut"] - fn mut_pop_ref(&mut self) -> Option<&'a mut T>; - /// Swaps two elements in a slice. /// /// Fails if `a` or `b` are out of bounds. @@ -730,12 +538,6 @@ pub trait MutableSlice<'a, T> { #[unstable = "waiting on final error conventions"] fn swap(self, a: uint, b: uint); - /// Deprecated: use `split_at_mut`. - #[deprecated = "use split_at_mut"] - fn mut_split_at(self, mid: uint) -> (&'a mut [T], &'a mut [T]) { - self.split_at_mut(mid) - } - /// Divides one `&mut` into two at an index. /// /// The first will contain all indices from `[0, mid)` (excluding @@ -783,12 +585,6 @@ pub trait MutableSlice<'a, T> { #[experimental = "may be moved to iterators instead"] fn reverse(self); - /// Deprecated: use `unsafe_mut`. - #[deprecated = "use unsafe_mut"] - unsafe fn unsafe_mut_ref(self, index: uint) -> &'a mut T { - self.unsafe_mut(index) - } - /// Returns an unsafe mutable pointer to the element in index #[experimental = "waiting on unsafe conventions"] unsafe fn unsafe_mut(self, index: uint) -> &'a mut T; @@ -803,18 +599,6 @@ pub trait MutableSlice<'a, T> { #[inline] #[unstable] fn as_mut_ptr(self) -> *mut T; - - /// Deprecated: use `*foo.as_mut_ptr().offset(index) = val` instead. - #[deprecated = "use `*foo.as_mut_ptr().offset(index) = val`"] - unsafe fn unsafe_set(self, index: uint, val: T); - - /// Deprecated: use `ptr::write(foo.as_mut_ptr().offset(i), val)` instead. - #[deprecated = "use `ptr::write(foo.as_mut_ptr().offset(i), val)`"] - unsafe fn init_elem(self, i: uint, val: T); - - /// Deprecated: use `as_mut_ptr` and `ptr::copy_memory` instead. - #[deprecated = "use as_mut_ptr and ptr::copy_memory"] - unsafe fn copy_memory(self, src: &[T]); } #[experimental = "trait is experimental"] @@ -920,30 +704,6 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { MutChunks { v: self, chunk_size: chunk_size } } - fn mut_shift_ref(&mut self) -> Option<&'a mut T> { - unsafe { - let s: &mut RawSlice<T> = transmute(self); - match raw::shift_ptr(s) { - // FIXME #13933: this `&` -> `&mut` cast is a little - // dubious - Some(p) => Some(&mut *(p as *mut _)), - None => None, - } - } - } - - fn mut_pop_ref(&mut self) -> Option<&'a mut T> { - unsafe { - let s: &mut RawSlice<T> = transmute(self); - match raw::pop_ptr(s) { - // FIXME #13933: this `&` -> `&mut` cast is a little - // dubious - Some(p) => Some(&mut *(p as *mut _)), - None => None, - } - } - } - fn swap(self, a: uint, b: uint) { unsafe { // Can't take two mutable loans from one vector, so instead just cast @@ -977,23 +737,6 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { fn as_mut_ptr(self) -> *mut T { self.repr().data as *mut T } - - #[inline] - unsafe fn unsafe_set(self, index: uint, val: T) { - *self.unsafe_mut(index) = val; - } - - #[inline] - unsafe fn init_elem(self, i: uint, val: T) { - ptr::write(&mut (*self.as_mut_ptr().offset(i as int)), val); - } - - #[inline] - unsafe fn copy_memory(self, src: &[T]) { - let len_src = src.len(); - assert!(self.len() >= len_src); - ptr::copy_nonoverlapping_memory(self.as_mut_ptr(), src.as_ptr(), len_src) - } } /// Extension methods for slices containing `PartialEq` elements. @@ -1048,10 +791,6 @@ impl<'a,T:PartialEq> ImmutablePartialEqSlice<T> for &'a [T] { /// Extension methods for slices containing `Ord` elements. #[unstable = "may merge with other traits"] pub trait ImmutableOrdSlice<T: Ord> { - /// Deprecated: use `binary_search_elem`. - #[deprecated = "use binary_search_elem"] - fn bsearch_elem(&self, x: &T) -> Option<uint>; - /// Binary search a sorted slice for a given element. /// /// If the value is found then `Found` is returned, containing the @@ -1082,12 +821,6 @@ pub trait ImmutableOrdSlice<T: Ord> { #[unstable = "trait is unstable"] impl<'a, T: Ord> ImmutableOrdSlice<T> for &'a [T] { - #[deprecated = "use binary_search_elem"] - #[allow(deprecated)] - fn bsearch_elem(&self, x: &T) -> Option<uint> { - self.bsearch(|p| p.cmp(x)) - } - #[unstable] fn binary_search_elem(&self, x: &T) -> BinarySearchResult { self.binary_search(|p| p.cmp(x)) @@ -1100,12 +833,6 @@ pub trait MutableCloneableSlice<T> { /// Copies as many elements from `src` as it can into `self` (the /// shorter of `self.len()` and `src.len()`). Returns the number /// of elements copied. - #[deprecated = "renamed to clone_from_slice"] - fn copy_from(self, s: &[T]) -> uint { self.clone_from_slice(s) } - - /// Copies as many elements from `src` as it can into `self` (the - /// shorter of `self.len()` and `src.len()`). Returns the number - /// of elements copied. /// /// # Example /// @@ -1780,7 +1507,7 @@ pub mod raw { pub mod bytes { use collections::Collection; use ptr; - use slice::MutableSlice; + use slice::{ImmutableSlice, MutableSlice}; /// A trait for operations on mutable `[u8]`s. pub trait MutableByteVector { @@ -1801,10 +1528,14 @@ pub mod bytes { /// `src` and `dst` must not overlap. Fails if the length of `dst` /// is less than the length of `src`. #[inline] - #[allow(deprecated)] pub fn copy_memory(dst: &mut [u8], src: &[u8]) { - // Bound checks are done at .copy_memory. - unsafe { dst.copy_memory(src) } + let len_src = src.len(); + assert!(dst.len() >= len_src); + unsafe { + ptr::copy_nonoverlapping_memory(dst.as_mut_ptr(), + src.as_ptr(), + len_src); + } } } |
