std: Stabilize APIs for the 1.9 release
This commit applies all stabilizations, renamings, and deprecations that the library team has decided on for the upcoming 1.9 release. All tracking issues have gone through a cycle-long "final comment period" and the specific APIs stabilized/deprecated are: Stable * `std::panic` * `std::panic::catch_unwind` (renamed from `recover`) * `std::panic::resume_unwind` (renamed from `propagate`) * `std::panic::AssertUnwindSafe` (renamed from `AssertRecoverSafe`) * `std::panic::UnwindSafe` (renamed from `RecoverSafe`) * `str::is_char_boundary` * `<*const T>::as_ref` * `<*mut T>::as_ref` * `<*mut T>::as_mut` * `AsciiExt::make_ascii_uppercase` * `AsciiExt::make_ascii_lowercase` * `char::decode_utf16` * `char::DecodeUtf16` * `char::DecodeUtf16Error` * `char::DecodeUtf16Error::unpaired_surrogate` * `BTreeSet::take` * `BTreeSet::replace` * `BTreeSet::get` * `HashSet::take` * `HashSet::replace` * `HashSet::get` * `OsString::with_capacity` * `OsString::clear` * `OsString::capacity` * `OsString::reserve` * `OsString::reserve_exact` * `OsStr::is_empty` * `OsStr::len` * `std::os::unix::thread` * `RawPthread` * `JoinHandleExt` * `JoinHandleExt::as_pthread_t` * `JoinHandleExt::into_pthread_t` * `HashSet::hasher` * `HashMap::hasher` * `CommandExt::exec` * `File::try_clone` * `SocketAddr::set_ip` * `SocketAddr::set_port` * `SocketAddrV4::set_ip` * `SocketAddrV4::set_port` * `SocketAddrV6::set_ip` * `SocketAddrV6::set_port` * `SocketAddrV6::set_flowinfo` * `SocketAddrV6::set_scope_id` * `<[T]>::copy_from_slice` * `ptr::read_volatile` * `ptr::write_volatile` * The `#[deprecated]` attribute * `OpenOptions::create_new` Deprecated * `std::raw::Slice` - use raw parts of `slice` module instead * `std::raw::Repr` - use raw parts of `slice` module instead * `str::char_range_at` - use slicing plus `chars()` plus `len_utf8` * `str::char_range_at_reverse` - use slicing plus `chars().rev()` plus `len_utf8` * `str::char_at` - use slicing plus `chars()` * `str::char_at_reverse` - use slicing plus `chars().rev()` * `str::slice_shift_char` - use `chars()` plus `Chars::as_str` * `CommandExt::session_leader` - use `before_exec` instead. Closes #27719 cc #27751 (deprecating the `Slice` bits) Closes #27754 Closes #27780 Closes #27809 Closes #27811 Closes #27830 Closes #28050 Closes #29453 Closes #29791 Closes #29935 Closes #30014 Closes #30752 Closes #31262 cc #31398 (still need to deal with `before_exec`) Closes #31405 Closes #31572 Closes #31755 Closes #31756
This commit is contained in:
parent
8694b4ffe9
commit
552eda70d3
58 changed files with 507 additions and 327 deletions
|
@ -29,7 +29,6 @@ use marker::Sized;
|
|||
use mem;
|
||||
use ops::{Fn, FnMut, FnOnce};
|
||||
use option::Option::{self, None, Some};
|
||||
use raw::{Repr, Slice};
|
||||
use result::Result::{self, Ok, Err};
|
||||
use slice::{self, SliceExt};
|
||||
|
||||
|
@ -1664,24 +1663,23 @@ pub trait StrExt {
|
|||
#[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")]
|
||||
#[stable(feature = "is_char_boundary", since = "1.9.0")]
|
||||
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")]
|
||||
#[rustc_deprecated(reason = "use slicing plus chars() plus len_utf8",
|
||||
since = "1.9.0")]
|
||||
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")]
|
||||
#[rustc_deprecated(reason = "use slicing plus chars().rev() plus len_utf8",
|
||||
since = "1.9.0")]
|
||||
fn char_range_at_reverse(&self, start: usize) -> CharRange;
|
||||
#[unstable(feature = "str_char",
|
||||
reason = "frequently replaced by the chars() iterator, this \
|
||||
|
@ -1690,12 +1688,16 @@ pub trait StrExt {
|
|||
iterators or by getting the first char from a \
|
||||
subslice",
|
||||
issue = "27754")]
|
||||
#[rustc_deprecated(reason = "use slicing plus chars()",
|
||||
since = "1.9.0")]
|
||||
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")]
|
||||
#[rustc_deprecated(reason = "use slicing plus chars().rev()",
|
||||
since = "1.9.0")]
|
||||
fn char_at_reverse(&self, i: usize) -> char;
|
||||
#[stable(feature = "core", since = "1.6.0")]
|
||||
fn as_bytes(&self) -> &[u8];
|
||||
|
@ -1714,6 +1716,8 @@ pub trait StrExt {
|
|||
may not be warranted with the existence of the chars \
|
||||
and/or char_indices iterators",
|
||||
issue = "27754")]
|
||||
#[rustc_deprecated(reason = "use chars() plus Chars::as_str",
|
||||
since = "1.9.0")]
|
||||
fn slice_shift_char(&self) -> Option<(char, &str)>;
|
||||
#[stable(feature = "core", since = "1.6.0")]
|
||||
fn as_ptr(&self) -> *const u8;
|
||||
|
@ -1857,18 +1861,16 @@ impl StrExt for str {
|
|||
|
||||
#[inline]
|
||||
unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str {
|
||||
mem::transmute(Slice {
|
||||
data: self.as_ptr().offset(begin as isize),
|
||||
len: end - begin,
|
||||
})
|
||||
let ptr = self.as_ptr().offset(begin as isize);
|
||||
let len = end - begin;
|
||||
from_utf8_unchecked(slice::from_raw_parts(ptr, len))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str {
|
||||
mem::transmute(Slice {
|
||||
data: self.as_ptr().offset(begin as isize),
|
||||
len: end - begin,
|
||||
})
|
||||
let ptr = self.as_ptr().offset(begin as isize);
|
||||
let len = end - begin;
|
||||
mem::transmute(slice::from_raw_parts_mut(ptr as *mut u8, len))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -1982,11 +1984,13 @@ impl StrExt for str {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(deprecated)]
|
||||
fn char_at(&self, i: usize) -> char {
|
||||
self.char_range_at(i).ch
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(deprecated)]
|
||||
fn char_at_reverse(&self, i: usize) -> char {
|
||||
self.char_range_at_reverse(i).ch
|
||||
}
|
||||
|
@ -2038,6 +2042,7 @@ impl StrExt for str {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(deprecated)]
|
||||
fn slice_shift_char(&self) -> Option<(char, &str)> {
|
||||
if self.is_empty() {
|
||||
None
|
||||
|
@ -2054,7 +2059,9 @@ impl StrExt for str {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn len(&self) -> usize { self.repr().len }
|
||||
fn len(&self) -> usize {
|
||||
self.as_bytes().len()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_empty(&self) -> bool { self.len() == 0 }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue