Skip to content

std: Clean out #[deprecated] APIs #23873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -977,17 +977,13 @@ An example of `use` declarations:

```
# #![feature(core)]
use std::iter::range_step;
use std::option::Option::{Some, None};
use std::collections::hash_map::{self, HashMap};

fn foo<T>(_: T){}
fn bar(map1: HashMap<String, usize>, map2: hash_map::HashMap<String, usize>){}

fn main() {
// Equivalent to 'std::iter::range_step(0, 10, 2);'
range_step(0, 10, 2);

// Equivalent to 'foo(vec![std::option::Option::Some(1.0f64),
// std::option::Option::None]);'
foo(vec![Some(1.0f64), None]);
Expand Down
13 changes: 7 additions & 6 deletions src/doc/trpl/iterators.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,12 @@ for num in nums.iter() {
```

These two basic iterators should serve you well. There are some more
advanced iterators, including ones that are infinite. Like `count`:
advanced iterators, including ones that are infinite. Like using range syntax
and `step_by`:

```rust
# #![feature(core)]
std::iter::count(1, 5);
# #![feature(step_by)]
(1..).step_by(5);
```

This iterator counts up from one, adding five each time. It will give
Expand Down Expand Up @@ -292,11 +293,11 @@ just use `for` instead.
There are tons of interesting iterator adapters. `take(n)` will return an
iterator over the next `n` elements of the original iterator, note that this
has no side effect on the original iterator. Let's try it out with our infinite
iterator from before, `count()`:
iterator from before:

```rust
# #![feature(core)]
for i in std::iter::count(1, 5).take(5) {
# #![feature(step_by)]
for i in (1..).step_by(5).take(5) {
println!("{}", i);
}
```
Expand Down
12 changes: 2 additions & 10 deletions src/libcollections/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
//! [sieve]: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
//!
//! ```
//! # #![feature(collections, core)]
//! # #![feature(collections, core, step_by)]
//! use std::collections::{BitSet, BitVec};
//! use std::num::Float;
//! use std::iter;
Expand All @@ -60,7 +60,7 @@
//! if bv[i] {
//! // Mark all multiples of i as non-prime (any multiples below i * i
//! // will have been marked as non-prime previously)
//! for j in iter::range_step(i * i, max_prime, i) { bv.set(j, false) }
//! for j in (i * i..max_prime).step_by(i) { bv.set(j, false) }
//! }
//! }
//! BitSet::from_bit_vec(bv)
Expand Down Expand Up @@ -1264,14 +1264,6 @@ impl BitSet {
BitSet { bit_vec: bit_vec }
}

/// Deprecated: use `from_bit_vec`.
#[inline]
#[deprecated(since = "1.0.0", reason = "renamed to from_bit_vec")]
#[unstable(feature = "collections")]
pub fn from_bitv(bit_vec: BitVec) -> BitSet {
BitSet { bit_vec: bit_vec }
}

/// Returns the capacity in bits for this bit vector. Inserting any
/// element less than this amount will not trigger a resizing.
///
Expand Down
20 changes: 0 additions & 20 deletions src/libcollections/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,26 +192,6 @@ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
Owned(owned) => owned
}
}

/// Returns true if this `Cow` wraps a borrowed value
#[deprecated(since = "1.0.0", reason = "match on the enum instead")]
#[unstable(feature = "std_misc")]
pub fn is_borrowed(&self) -> bool {
match *self {
Borrowed(_) => true,
_ => false,
}
}

/// Returns true if this `Cow` wraps an owned value
#[deprecated(since = "1.0.0", reason = "match on the enum instead")]
#[unstable(feature = "std_misc")]
pub fn is_owned(&self) -> bool {
match *self {
Owned(_) => true,
_ => false,
}
}
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
24 changes: 0 additions & 24 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,6 @@ pub use string::String;
pub use vec::Vec;
pub use vec_map::VecMap;

#[deprecated(since = "1.0.0", reason = "renamed to vec_deque")]
#[unstable(feature = "collections")]
pub use vec_deque as ring_buf;

#[deprecated(since = "1.0.0", reason = "renamed to linked_list")]
#[unstable(feature = "collections")]
pub use linked_list as dlist;

#[deprecated(since = "1.0.0", reason = "renamed to bit_vec")]
#[unstable(feature = "collections")]
pub use bit_vec as bitv;

#[deprecated(since = "1.0.0", reason = "renamed to bit_set")]
#[unstable(feature = "collections")]
pub use bit_set as bitv_set;

// Needed for the vec! macro
pub use alloc::boxed;

Expand All @@ -108,21 +92,13 @@ pub mod vec_map;
reason = "RFC 509")]
pub mod bit_vec {
pub use bit::{BitVec, Iter};

#[deprecated(since = "1.0.0", reason = "renamed to BitVec")]
#[unstable(feature = "collections")]
pub use bit::BitVec as Bitv;
}

#[unstable(feature = "collections",
reason = "RFC 509")]
pub mod bit_set {
pub use bit::{BitSet, Union, Intersection, Difference, SymmetricDifference};
pub use bit::SetIter as Iter;

#[deprecated(since = "1.0.0", reason = "renamed to BitSet")]
#[unstable(feature = "collections")]
pub use bit::BitSet as BitvSet;
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
6 changes: 1 addition & 5 deletions src/libcollections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ use core::iter::{self, FromIterator, IntoIterator};
use core::mem;
use core::ptr;

#[deprecated(since = "1.0.0", reason = "renamed to LinkedList")]
#[unstable(feature = "collections")]
pub use LinkedList as DList;

/// A doubly-linked list.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct LinkedList<T> {
Expand Down Expand Up @@ -844,7 +840,7 @@ impl<A> ExactSizeIterator for IntoIter<A> {}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A> FromIterator<A> for LinkedList<A> {
fn from_iter<T: IntoIterator<Item=A>>(iter: T) -> LinkedList<A> {
let mut ret = DList::new();
let mut ret = LinkedList::new();
ret.extend(iter);
ret
}
Expand Down
71 changes: 0 additions & 71 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ pub use core::slice::{IntSliceExt, SplitMut, ChunksMut, Split};
pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut};
pub use core::slice::{bytes, mut_ref_slice, ref_slice};
pub use core::slice::{from_raw_parts, from_raw_parts_mut};
pub use core::slice::{from_raw_buf, from_raw_mut_buf};

////////////////////////////////////////////////////////////////////////////////
// Basic slice extension methods
Expand Down Expand Up @@ -281,33 +280,6 @@ impl<T> [T] {
cmp::min(self.len(), end-start)
}

/// Deprecated: use `&s[start .. end]` notation instead.
#[unstable(feature = "collections",
reason = "will be replaced by slice syntax")]
#[deprecated(since = "1.0.0", reason = "use &s[start .. end] instead")]
#[inline]
pub fn slice(&self, start: usize, end: usize) -> &[T] {
&self[start .. end]
}

/// Deprecated: use `&s[start..]` notation instead.
#[unstable(feature = "collections",
reason = "will be replaced by slice syntax")]
#[deprecated(since = "1.0.0", reason = "use &s[start..] instead")]
#[inline]
pub fn slice_from(&self, start: usize) -> &[T] {
&self[start ..]
}

/// Deprecated: use `&s[..end]` notation instead.
#[unstable(feature = "collections",
reason = "will be replaced by slice syntax")]
#[deprecated(since = "1.0.0", reason = "use &s[..end] instead")]
#[inline]
pub fn slice_to(&self, end: usize) -> &[T] {
&self[.. end]
}

/// Divides one slice into two at an index.
///
/// The first will contain all indices from `[0, mid)` (excluding
Expand Down Expand Up @@ -611,42 +583,6 @@ impl<T> [T] {
core_slice::SliceExt::get_mut(self, index)
}

/// Deprecated: use `&mut s[..]` instead.
#[unstable(feature = "collections",
reason = "will be replaced by slice syntax")]
#[deprecated(since = "1.0.0", reason = "use &mut s[..] instead")]
#[allow(deprecated)]
pub fn as_mut_slice(&mut self) -> &mut [T] {
core_slice::SliceExt::as_mut_slice(self)
}

/// Deprecated: use `&mut s[start .. end]` instead.
#[unstable(feature = "collections",
reason = "will be replaced by slice syntax")]
#[deprecated(since = "1.0.0", reason = "use &mut s[start .. end] instead")]
#[inline]
pub fn slice_mut(&mut self, start: usize, end: usize) -> &mut [T] {
&mut self[start .. end]
}

/// Deprecated: use `&mut s[start ..]` instead.
#[unstable(feature = "collections",
reason = "will be replaced by slice syntax")]
#[deprecated(since = "1.0.0", reason = "use &mut s[start ..] instead")]
#[inline]
pub fn slice_from_mut(&mut self, start: usize) -> &mut [T] {
&mut self[start ..]
}

/// Deprecated: use `&mut s[.. end]` instead.
#[unstable(feature = "collections",
reason = "will be replaced by slice syntax")]
#[deprecated(since = "1.0.0", reason = "use &mut s[.. end] instead")]
#[inline]
pub fn slice_to_mut(&mut self, end: usize) -> &mut [T] {
&mut self[.. end]
}

/// Returns an iterator that allows modifying each value
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down Expand Up @@ -937,13 +873,6 @@ impl<T> [T] {
core_slice::SliceExt::binary_search(self, x)
}

/// Deprecated: use `binary_search` instead.
#[unstable(feature = "collections")]
#[deprecated(since = "1.0.0", reason = "use binary_search instead")]
pub fn binary_search_elem(&self, x: &T) -> Result<usize, usize> where T: Ord {
self.binary_search(x)
}

/// Mutates the slice to the next lexicographic permutation.
///
/// Returns `true` if successful and `false` if the slice is at the
Expand Down
87 changes: 3 additions & 84 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ use vec::Vec;
use slice::SliceConcatExt;

pub use core::str::{FromStr, Utf8Error, Str};
pub use core::str::{Lines, LinesAny, MatchIndices, SplitStr, CharRange};
pub use core::str::{Lines, LinesAny, MatchIndices, CharRange};
pub use core::str::{Split, SplitTerminator, SplitN};
pub use core::str::{RSplit, RSplitN};
pub use core::str::{from_utf8, CharEq, Chars, CharIndices, Bytes};
pub use core::str::{from_utf8_unchecked, from_c_str, ParseBoolError};
pub use core::str::{from_utf8, Chars, CharIndices, Bytes};
pub use core::str::{from_utf8_unchecked, ParseBoolError};
pub use unicode::str::{Words, Graphemes, GraphemeIndices};
pub use core::str::Pattern;
pub use core::str::{Searcher, ReverseSearcher, DoubleEndedSearcher, SearchStep};
Expand Down Expand Up @@ -536,22 +536,6 @@ impl str {
core_str::StrExt::contains(&self[..], pat)
}

/// Returns `true` if `self` contains a `char`.
///
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// assert!("hello".contains_char('e'));
///
/// assert!(!"hello".contains_char('z'));
/// ```
#[unstable(feature = "collections")]
#[deprecated(since = "1.0.0", reason = "use `contains()` with a char")]
pub fn contains_char<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool {
core_str::StrExt::contains_char(&self[..], pat)
}

/// An iterator over the codepoints of `self`.
///
/// # Examples
Expand Down Expand Up @@ -778,25 +762,6 @@ impl str {
core_str::StrExt::match_indices(&self[..], pat)
}

/// An iterator over the substrings of `self` separated by a `&str`.
///
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let v: Vec<&str> = "abcXXXabcYYYabc".split_str("abc").collect();
/// assert_eq!(v, ["", "XXX", "YYY", ""]);
///
/// let v: Vec<&str> = "1abcabc2".split_str("abc").collect();
/// assert_eq!(v, ["1", "", "2"]);
/// ```
#[unstable(feature = "collections")]
#[deprecated(since = "1.0.0", reason = "use `split()` with a `&str`")]
#[allow(deprecated) /* for SplitStr */]
pub fn split_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitStr<'a, P> {
core_str::StrExt::split_str(&self[..], pat)
}

/// An iterator over the lines of a string, separated by `\n`.
///
/// This does not include the empty string after a trailing `\n`.
Expand Down Expand Up @@ -848,31 +813,6 @@ impl str {
pub fn lines_any(&self) -> LinesAny {
core_str::StrExt::lines_any(&self[..])
}

/// Deprecated: use `s[a .. b]` instead.
#[unstable(feature = "collections",
reason = "use slice notation [a..b] instead")]
#[deprecated(since = "1.0.0", reason = "use slice notation [a..b] instead")]
pub fn slice(&self, begin: usize, end: usize) -> &str {
&self[begin..end]
}

/// Deprecated: use `s[a..]` instead.
#[unstable(feature = "collections",
reason = "use slice notation [a..b] instead")]
#[deprecated(since = "1.0.0", reason = "use slice notation [a..] instead")]
pub fn slice_from(&self, begin: usize) -> &str {
&self[begin..]
}

/// Deprecated: use `s[..a]` instead.
#[unstable(feature = "collections",
reason = "use slice notation [a..b] instead")]
#[deprecated(since = "1.0.0", reason = "use slice notation [..a] instead")]
pub fn slice_to(&self, end: usize) -> &str {
&self[..end]
}

/// Returns a slice of the string from the character range [`begin`..`end`).
///
/// That is, start at the `begin`-th code point of the string and continue
Expand Down Expand Up @@ -1306,27 +1246,6 @@ impl str {
core_str::StrExt::rfind(&self[..], pat)
}

/// Returns the byte index of the first matching substring if it exists.
///
/// Returns `None` if it doesn't exist.
///
/// The pattern can be a simple `&str`, or a closure that determines the split.
///
/// # Examples
///
/// ```
/// # #![feature(collections)]
/// let s = "Löwe 老虎 Léopard";
///
/// assert_eq!(s.find_str("老虎 L"), Some(6));
/// assert_eq!(s.find_str("muffin man"), None);
/// ```
#[unstable(feature = "collections")]
#[deprecated(since = "1.0.0", reason = "use `find()` with a `&str`")]
pub fn find_str<'a, P: Pattern<'a>>(&'a self, needle: P) -> Option<usize> {
core_str::StrExt::find_str(&self[..], needle)
}

/// Retrieves the first character from a `&str` and returns it.
///
/// This does not allocate a new string; instead, it returns a slice that points one character
Expand Down
Loading