1
Fork 0

std: Stabilize APIs for the 1.6 release

This commit is the standard API stabilization commit for the 1.6 release cycle.
The list of issues and APIs below have all been through their cycle-long FCP and
the libs team decisions are listed below

Stabilized APIs

* `Read::read_exact`
* `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`)
* libcore -- this was a bit of a nuanced stabilization, the crate itself is now
  marked as `#[stable]` and the methods appearing via traits for primitives like
  `char` and `str` are now also marked as stable. Note that the extension traits
  themeselves are marked as unstable as they're imported via the prelude. The
  `try!` macro was also moved from the standard library into libcore to have the
  same interface. Otherwise the functions all have copied stability from the
  standard library now.
* The `#![no_std]` attribute
* `fs::DirBuilder`
* `fs::DirBuilder::new`
* `fs::DirBuilder::recursive`
* `fs::DirBuilder::create`
* `os::unix::fs::DirBuilderExt`
* `os::unix::fs::DirBuilderExt::mode`
* `vec::Drain`
* `vec::Vec::drain`
* `string::Drain`
* `string::String::drain`
* `vec_deque::Drain`
* `vec_deque::VecDeque::drain`
* `collections::hash_map::Drain`
* `collections::hash_map::HashMap::drain`
* `collections::hash_set::Drain`
* `collections::hash_set::HashSet::drain`
* `collections::binary_heap::Drain`
* `collections::binary_heap::BinaryHeap::drain`
* `Vec::extend_from_slice` (renamed from `push_all`)
* `Mutex::get_mut`
* `Mutex::into_inner`
* `RwLock::get_mut`
* `RwLock::into_inner`
* `Iterator::min_by_key` (renamed from `min_by`)
* `Iterator::max_by_key` (renamed from `max_by`)

Deprecated APIs

* `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`)
* `OsString::from_bytes`
* `OsStr::to_cstring`
* `OsStr::to_bytes`
* `fs::walk_dir` and `fs::WalkDir`
* `path::Components::peek`
* `slice::bytes::MutableByteVector`
* `slice::bytes::copy_memory`
* `Vec::push_all` (renamed to `extend_from_slice`)
* `Duration::span`
* `IpAddr`
* `SocketAddr::ip`
* `Read::tee`
* `io::Tee`
* `Write::broadcast`
* `io::Broadcast`
* `Iterator::min_by` (renamed to `min_by_key`)
* `Iterator::max_by` (renamed to `max_by_key`)
* `net::lookup_addr`

New APIs (still unstable)

* `<[T]>::sort_by_key` (added to mirror `min_by_key`)

Closes #27585
Closes #27704
Closes #27707
Closes #27710
Closes #27711
Closes #27727
Closes #27740
Closes #27744
Closes #27799
Closes #27801
cc #27801 (doesn't close as `Chars` is still unstable)
Closes #28968
This commit is contained in:
Alex Crichton 2015-12-02 17:31:49 -08:00
parent ac0e845224
commit 464cdff102
165 changed files with 712 additions and 718 deletions

View file

@ -1385,58 +1385,120 @@ pub trait StrExt {
// NB there are no docs here are they're all located on the StrExt trait in
// libcollections, not here.
#[stable(feature = "core", since = "1.6.0")]
fn contains<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool;
fn contains_char<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn chars(&self) -> Chars;
#[stable(feature = "core", since = "1.6.0")]
fn bytes(&self) -> Bytes;
#[stable(feature = "core", since = "1.6.0")]
fn char_indices(&self) -> CharIndices;
#[stable(feature = "core", since = "1.6.0")]
fn split<'a, P: Pattern<'a>>(&'a self, pat: P) -> Split<'a, P>;
#[stable(feature = "core", since = "1.6.0")]
fn rsplit<'a, P: Pattern<'a>>(&'a self, pat: P) -> RSplit<'a, P>
where P::Searcher: ReverseSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn splitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> SplitN<'a, P>;
#[stable(feature = "core", since = "1.6.0")]
fn rsplitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> RSplitN<'a, P>
where P::Searcher: ReverseSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn split_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitTerminator<'a, P>;
#[stable(feature = "core", since = "1.6.0")]
fn rsplit_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> RSplitTerminator<'a, P>
where P::Searcher: ReverseSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> Matches<'a, P>;
#[stable(feature = "core", since = "1.6.0")]
fn rmatches<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatches<'a, P>
where P::Searcher: ReverseSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn match_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> MatchIndices<'a, P>;
#[stable(feature = "core", since = "1.6.0")]
fn rmatch_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatchIndices<'a, P>
where P::Searcher: ReverseSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn lines(&self) -> Lines;
#[stable(feature = "core", since = "1.6.0")]
#[rustc_deprecated(since = "1.6.0", reason = "use lines() instead now")]
#[allow(deprecated)]
fn lines_any(&self) -> LinesAny;
fn char_len(&self) -> usize;
fn slice_chars(&self, begin: usize, end: usize) -> &str;
#[stable(feature = "core", since = "1.6.0")]
unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str;
#[stable(feature = "core", since = "1.6.0")]
unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str;
#[stable(feature = "core", since = "1.6.0")]
fn starts_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn ends_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool
where P::Searcher: ReverseSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn trim_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
where P::Searcher: DoubleEndedSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn trim_left_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str;
#[stable(feature = "core", since = "1.6.0")]
fn trim_right_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
where P::Searcher: ReverseSearcher<'a>;
#[unstable(feature = "str_char",
reason = "it is unclear whether this method pulls its weight \
with the existence of the char_indices iterator or \
this method may want to be replaced with checked \
slicing",
issue = "27754")]
fn is_char_boundary(&self, index: usize) -> bool;
#[unstable(feature = "str_char",
reason = "often replaced by char_indices, this method may \
be removed in favor of just char_at() or eventually \
removed altogether",
issue = "27754")]
fn char_range_at(&self, start: usize) -> CharRange;
#[unstable(feature = "str_char",
reason = "often replaced by char_indices, this method may \
be removed in favor of just char_at_reverse() or \
eventually removed altogether",
issue = "27754")]
fn char_range_at_reverse(&self, start: usize) -> CharRange;
#[unstable(feature = "str_char",
reason = "frequently replaced by the chars() iterator, this \
method may be removed or possibly renamed in the \
future; it is normally replaced by chars/char_indices \
iterators or by getting the first char from a \
subslice",
issue = "27754")]
fn char_at(&self, i: usize) -> char;
#[unstable(feature = "str_char",
reason = "see char_at for more details, but reverse semantics \
are also somewhat unclear, especially with which \
cases generate panics",
issue = "27754")]
fn char_at_reverse(&self, i: usize) -> char;
#[stable(feature = "core", since = "1.6.0")]
fn as_bytes(&self) -> &[u8];
#[stable(feature = "core", since = "1.6.0")]
fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>;
#[stable(feature = "core", since = "1.6.0")]
fn rfind<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>
where P::Searcher: ReverseSearcher<'a>;
fn find_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>;
#[stable(feature = "core", since = "1.6.0")]
fn split_at(&self, mid: usize) -> (&str, &str);
#[stable(feature = "core", since = "1.6.0")]
fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str);
#[unstable(feature = "str_char",
reason = "awaiting conventions about shifting and slices and \
may not be warranted with the existence of the chars \
and/or char_indices iterators",
issue = "27754")]
fn slice_shift_char(&self) -> Option<(char, &str)>;
fn subslice_offset(&self, inner: &str) -> usize;
#[stable(feature = "core", since = "1.6.0")]
fn as_ptr(&self) -> *const u8;
#[stable(feature = "core", since = "1.6.0")]
fn len(&self) -> usize;
#[stable(feature = "core", since = "1.6.0")]
fn is_empty(&self) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn parse<T: FromStr>(&self) -> Result<T, T::Err>;
}
@ -1448,20 +1510,13 @@ fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! {
begin, end, s);
}
#[unstable(feature = "core_str_ext",
reason = "stable interface provided by `impl str` in later crates",
issue = "27701")]
#[stable(feature = "core", since = "1.6.0")]
impl StrExt for str {
#[inline]
fn contains<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool {
pat.is_contained_in(self)
}
#[inline]
fn contains_char<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool {
pat.is_contained_in(self)
}
#[inline]
fn chars(&self) -> Chars {
Chars{iter: self.as_bytes().iter()}
@ -1559,32 +1614,6 @@ impl StrExt for str {
LinesAny(self.lines())
}
#[inline]
fn char_len(&self) -> usize { self.chars().count() }
fn slice_chars(&self, begin: usize, end: usize) -> &str {
assert!(begin <= end);
let mut count = 0;
let mut begin_byte = None;
let mut end_byte = None;
// This could be even more efficient by not decoding,
// only finding the char boundaries
for (idx, _) in self.char_indices() {
if count == begin { begin_byte = Some(idx); }
if count == end { end_byte = Some(idx); break; }
count += 1;
}
if begin_byte.is_none() && count == begin { begin_byte = Some(self.len()) }
if end_byte.is_none() && count == end { end_byte = Some(self.len()) }
match (begin_byte, end_byte) {
(None, _) => panic!("slice_chars: `begin` is beyond end of string"),
(_, None) => panic!("slice_chars: `end` is beyond end of string"),
(Some(a), Some(b)) => unsafe { self.slice_unchecked(a, b) }
}
}
#[inline]
unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str {
mem::transmute(Slice {
@ -1774,17 +1803,6 @@ impl StrExt for str {
}
}
fn subslice_offset(&self, inner: &str) -> usize {
let a_start = self.as_ptr() as usize;
let a_end = a_start + self.len();
let b_start = inner.as_ptr() as usize;
let b_end = b_start + inner.len();
assert!(a_start <= b_start);
assert!(b_end <= a_end);
b_start - a_start
}
#[inline]
fn as_ptr(&self) -> *const u8 {
self.repr().data