Auto merge of #50017 - tinaun:stabilize-all-the-things, r=sfackler
stabilize a bunch of minor api additions besides `ptr::NonNull::cast` (which is 4 days away from end of FCP) all of these have been finished with FCP for a few weeks now with minimal issues raised * Closes #41020 * Closes #42818 * Closes #44030 * Closes #44400 * Closes #46507 * Closes #47653 * Closes #46344 the following functions will be stabilized in 1.27: * `[T]::rsplit` * `[T]::rsplit_mut` * `[T]::swap_with_slice` * `ptr::swap_nonoverlapping` * `NonNull::cast` * `Duration::from_micros` * `Duration::from_nanos` * `Duration::subsec_millis` * `Duration::subsec_micros` * `HashMap::remove_entry`
This commit is contained in:
commit
ac3c2288f9
9 changed files with 28 additions and 59 deletions
|
@ -1,10 +0,0 @@
|
|||
# `slice_rsplit`
|
||||
|
||||
The tracking issue for this feature is: [#41020]
|
||||
|
||||
[#41020]: https://github.com/rust-lang/rust/issues/41020
|
||||
|
||||
------------------------
|
||||
|
||||
The `slice_rsplit` feature enables two methods on slices:
|
||||
`slice.rsplit(predicate)` and `slice.rsplit_mut(predicate)`.
|
|
@ -99,7 +99,6 @@
|
|||
#![feature(lang_items)]
|
||||
#![feature(libc)]
|
||||
#![feature(needs_allocator)]
|
||||
#![feature(nonnull_cast)]
|
||||
#![feature(nonzero)]
|
||||
#![feature(optin_builtin_traits)]
|
||||
#![feature(pattern)]
|
||||
|
@ -108,7 +107,6 @@
|
|||
#![feature(ptr_offset_from)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(slice_get_slice)]
|
||||
#![feature(slice_rsplit)]
|
||||
#![feature(specialization)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(str_internals)]
|
||||
|
@ -124,7 +122,7 @@
|
|||
#![feature(inclusive_range_fields)]
|
||||
#![cfg_attr(stage0, feature(generic_param_attrs))]
|
||||
|
||||
#![cfg_attr(not(test), feature(fn_traits, swap_with_slice, i128))]
|
||||
#![cfg_attr(not(test), feature(fn_traits, i128))]
|
||||
#![cfg_attr(test, feature(test))]
|
||||
|
||||
// Allow testing this library
|
||||
|
|
|
@ -116,7 +116,7 @@ pub use core::slice::{Iter, IterMut};
|
|||
pub use core::slice::{SplitMut, ChunksMut, Split};
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut};
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
pub use core::slice::{RSplit, RSplitMut};
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use core::slice::{from_raw_parts, from_raw_parts_mut};
|
||||
|
@ -888,7 +888,6 @@ impl<T> [T] {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_rsplit)]
|
||||
///
|
||||
/// let slice = [11, 22, 33, 0, 44, 55];
|
||||
/// let mut iter = slice.rsplit(|num| *num == 0);
|
||||
|
@ -902,8 +901,6 @@ impl<T> [T] {
|
|||
/// slice will be the first (or last) item returned by the iterator.
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_rsplit)]
|
||||
///
|
||||
/// let v = &[0, 1, 1, 2, 3, 5, 8];
|
||||
/// let mut it = v.rsplit(|n| *n % 2 == 0);
|
||||
/// assert_eq!(it.next().unwrap(), &[]);
|
||||
|
@ -912,7 +909,7 @@ impl<T> [T] {
|
|||
/// assert_eq!(it.next().unwrap(), &[]);
|
||||
/// assert_eq!(it.next(), None);
|
||||
/// ```
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
#[inline]
|
||||
pub fn rsplit<F>(&self, pred: F) -> RSplit<T, F>
|
||||
where F: FnMut(&T) -> bool
|
||||
|
@ -927,8 +924,6 @@ impl<T> [T] {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_rsplit)]
|
||||
///
|
||||
/// let mut v = [100, 400, 300, 200, 600, 500];
|
||||
///
|
||||
/// let mut count = 0;
|
||||
|
@ -939,7 +934,7 @@ impl<T> [T] {
|
|||
/// assert_eq!(v, [3, 400, 300, 2, 600, 1]);
|
||||
/// ```
|
||||
///
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
#[inline]
|
||||
pub fn rsplit_mut<F>(&mut self, pred: F) -> RSplitMut<T, F>
|
||||
where F: FnMut(&T) -> bool
|
||||
|
@ -1707,8 +1702,6 @@ impl<T> [T] {
|
|||
/// Swapping two elements across slices:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(swap_with_slice)]
|
||||
///
|
||||
/// let mut slice1 = [0, 0];
|
||||
/// let mut slice2 = [1, 2, 3, 4];
|
||||
///
|
||||
|
@ -1724,8 +1717,6 @@ impl<T> [T] {
|
|||
/// a compile failure:
|
||||
///
|
||||
/// ```compile_fail
|
||||
/// #![feature(swap_with_slice)]
|
||||
///
|
||||
/// let mut slice = [1, 2, 3, 4, 5];
|
||||
/// slice[..2].swap_with_slice(&mut slice[3..]); // compile fail!
|
||||
/// ```
|
||||
|
@ -1734,8 +1725,6 @@ impl<T> [T] {
|
|||
/// mutable sub-slices from a slice:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(swap_with_slice)]
|
||||
///
|
||||
/// let mut slice = [1, 2, 3, 4, 5];
|
||||
///
|
||||
/// {
|
||||
|
@ -1747,7 +1736,7 @@ impl<T> [T] {
|
|||
/// ```
|
||||
///
|
||||
/// [`split_at_mut`]: #method.split_at_mut
|
||||
#[unstable(feature = "swap_with_slice", issue = "44030")]
|
||||
#[stable(feature = "swap_with_slice", since = "1.27.0")]
|
||||
pub fn swap_with_slice(&mut self, other: &mut [T]) {
|
||||
core_slice::SliceExt::swap_with_slice(self, other)
|
||||
}
|
||||
|
|
|
@ -166,8 +166,6 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
|
|||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(swap_nonoverlapping)]
|
||||
///
|
||||
/// use std::ptr;
|
||||
///
|
||||
/// let mut x = [1, 2, 3, 4];
|
||||
|
@ -181,7 +179,7 @@ pub unsafe fn swap<T>(x: *mut T, y: *mut T) {
|
|||
/// assert_eq!(y, [1, 2, 9]);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "swap_nonoverlapping", issue = "42818")]
|
||||
#[stable(feature = "swap_nonoverlapping", since = "1.27.0")]
|
||||
pub unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
|
||||
let x = x as *mut u8;
|
||||
let y = y as *mut u8;
|
||||
|
@ -2744,7 +2742,7 @@ impl<T: ?Sized> NonNull<T> {
|
|||
}
|
||||
|
||||
/// Cast to a pointer of another type
|
||||
#[unstable(feature = "nonnull_cast", issue = "47653")]
|
||||
#[stable(feature = "nonnull_cast", since = "1.27.0")]
|
||||
pub fn cast<U>(self) -> NonNull<U> {
|
||||
unsafe {
|
||||
NonNull::new_unchecked(self.as_ptr() as *mut U)
|
||||
|
|
|
@ -86,7 +86,7 @@ pub trait SliceExt {
|
|||
fn split<P>(&self, pred: P) -> Split<Self::Item, P>
|
||||
where P: FnMut(&Self::Item) -> bool;
|
||||
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
fn rsplit<P>(&self, pred: P) -> RSplit<Self::Item, P>
|
||||
where P: FnMut(&Self::Item) -> bool;
|
||||
|
||||
|
@ -169,7 +169,7 @@ pub trait SliceExt {
|
|||
fn split_mut<P>(&mut self, pred: P) -> SplitMut<Self::Item, P>
|
||||
where P: FnMut(&Self::Item) -> bool;
|
||||
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
fn rsplit_mut<P>(&mut self, pred: P) -> RSplitMut<Self::Item, P>
|
||||
where P: FnMut(&Self::Item) -> bool;
|
||||
|
||||
|
@ -223,7 +223,7 @@ pub trait SliceExt {
|
|||
#[stable(feature = "copy_from_slice", since = "1.9.0")]
|
||||
fn copy_from_slice(&mut self, src: &[Self::Item]) where Self::Item: Copy;
|
||||
|
||||
#[unstable(feature = "swap_with_slice", issue = "44030")]
|
||||
#[stable(feature = "swap_with_slice", since = "1.27.0")]
|
||||
fn swap_with_slice(&mut self, src: &mut [Self::Item]);
|
||||
|
||||
#[stable(feature = "sort_unstable", since = "1.20.0")]
|
||||
|
@ -1840,13 +1840,13 @@ impl<'a, T, P> FusedIterator for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {
|
|||
///
|
||||
/// [`rsplit`]: ../../std/primitive.slice.html#method.rsplit
|
||||
/// [slices]: ../../std/primitive.slice.html
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
#[derive(Clone)] // Is this correct, or does it incorrectly require `T: Clone`?
|
||||
pub struct RSplit<'a, T:'a, P> where P: FnMut(&T) -> bool {
|
||||
inner: Split<'a, T, P>
|
||||
}
|
||||
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("RSplit")
|
||||
|
@ -1856,7 +1856,7 @@ impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplit<'a, T, P> where P: FnMut(&
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
impl<'a, T, P> Iterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
type Item = &'a [T];
|
||||
|
||||
|
@ -1871,7 +1871,7 @@ impl<'a, T, P> Iterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
impl<'a, T, P> DoubleEndedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a [T]> {
|
||||
|
@ -1879,7 +1879,7 @@ impl<'a, T, P> DoubleEndedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bo
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
impl<'a, T, P> SplitIter for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
#[inline]
|
||||
fn finish(&mut self) -> Option<&'a [T]> {
|
||||
|
@ -1887,7 +1887,7 @@ impl<'a, T, P> SplitIter for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
impl<'a, T, P> FusedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {}
|
||||
|
||||
/// An iterator over the subslices of the vector which are separated
|
||||
|
@ -1897,12 +1897,12 @@ impl<'a, T, P> FusedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {}
|
|||
///
|
||||
/// [`rsplit_mut`]: ../../std/primitive.slice.html#method.rsplit_mut
|
||||
/// [slices]: ../../std/primitive.slice.html
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
pub struct RSplitMut<'a, T:'a, P> where P: FnMut(&T) -> bool {
|
||||
inner: SplitMut<'a, T, P>
|
||||
}
|
||||
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("RSplitMut")
|
||||
|
@ -1912,7 +1912,7 @@ impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitMut<'a, T, P> where P: FnMu
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
impl<'a, T, P> SplitIter for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
#[inline]
|
||||
fn finish(&mut self) -> Option<&'a mut [T]> {
|
||||
|
@ -1920,7 +1920,7 @@ impl<'a, T, P> SplitIter for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
impl<'a, T, P> Iterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
|
||||
type Item = &'a mut [T];
|
||||
|
||||
|
@ -1935,7 +1935,7 @@ impl<'a, T, P> Iterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
impl<'a, T, P> DoubleEndedIterator for RSplitMut<'a, T, P> where
|
||||
P: FnMut(&T) -> bool,
|
||||
{
|
||||
|
@ -1945,7 +1945,7 @@ impl<'a, T, P> DoubleEndedIterator for RSplitMut<'a, T, P> where
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "slice_rsplit", issue = "41020")]
|
||||
#[stable(feature = "slice_rsplit", since = "1.27.0")]
|
||||
impl<'a, T, P> FusedIterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {}
|
||||
|
||||
/// An private iterator over subslices separated by elements that
|
||||
|
|
|
@ -137,7 +137,6 @@ impl Duration {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(duration_from_micros)]
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// let duration = Duration::from_micros(1_000_002);
|
||||
|
@ -145,7 +144,7 @@ impl Duration {
|
|||
/// assert_eq!(1, duration.as_secs());
|
||||
/// assert_eq!(2000, duration.subsec_nanos());
|
||||
/// ```
|
||||
#[unstable(feature = "duration_from_micros", issue = "44400")]
|
||||
#[stable(feature = "duration_from_micros", since = "1.27.0")]
|
||||
#[inline]
|
||||
pub const fn from_micros(micros: u64) -> Duration {
|
||||
Duration {
|
||||
|
@ -159,7 +158,6 @@ impl Duration {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(duration_extras)]
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// let duration = Duration::from_nanos(1_000_000_123);
|
||||
|
@ -167,7 +165,7 @@ impl Duration {
|
|||
/// assert_eq!(1, duration.as_secs());
|
||||
/// assert_eq!(123, duration.subsec_nanos());
|
||||
/// ```
|
||||
#[unstable(feature = "duration_extras", issue = "46507")]
|
||||
#[stable(feature = "duration_extras", since = "1.27.0")]
|
||||
#[inline]
|
||||
pub const fn from_nanos(nanos: u64) -> Duration {
|
||||
Duration {
|
||||
|
@ -217,14 +215,13 @@ impl Duration {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(duration_extras)]
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// let duration = Duration::from_millis(5432);
|
||||
/// assert_eq!(duration.as_secs(), 5);
|
||||
/// assert_eq!(duration.subsec_millis(), 432);
|
||||
/// ```
|
||||
#[unstable(feature = "duration_extras", issue = "46507")]
|
||||
#[stable(feature = "duration_extras", since = "1.27.0")]
|
||||
#[inline]
|
||||
pub fn subsec_millis(&self) -> u32 { self.nanos / NANOS_PER_MILLI }
|
||||
|
||||
|
@ -237,14 +234,13 @@ impl Duration {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(duration_extras, duration_from_micros)]
|
||||
/// use std::time::Duration;
|
||||
///
|
||||
/// let duration = Duration::from_micros(1_234_567);
|
||||
/// assert_eq!(duration.as_secs(), 1);
|
||||
/// assert_eq!(duration.subsec_micros(), 234_567);
|
||||
/// ```
|
||||
#[unstable(feature = "duration_extras", issue = "46507")]
|
||||
#[stable(feature = "duration_extras", since = "1.27.0")]
|
||||
#[inline]
|
||||
pub fn subsec_micros(&self) -> u32 { self.nanos / NANOS_PER_MICRO }
|
||||
|
||||
|
|
|
@ -1379,7 +1379,6 @@ impl<K, V, S> HashMap<K, V, S>
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(hash_map_remove_entry)]
|
||||
/// use std::collections::HashMap;
|
||||
///
|
||||
/// # fn main() {
|
||||
|
@ -1389,7 +1388,7 @@ impl<K, V, S> HashMap<K, V, S>
|
|||
/// assert_eq!(map.remove(&1), None);
|
||||
/// # }
|
||||
/// ```
|
||||
#[unstable(feature = "hash_map_remove_entry", issue = "46344")]
|
||||
#[stable(feature = "hash_map_remove_entry", since = "1.27.0")]
|
||||
pub fn remove_entry<Q: ?Sized>(&mut self, k: &Q) -> Option<(K, V)>
|
||||
where K: Borrow<Q>,
|
||||
Q: Hash + Eq
|
||||
|
|
|
@ -275,7 +275,6 @@
|
|||
#![feature(macro_reexport)]
|
||||
#![feature(macro_vis_matcher)]
|
||||
#![feature(needs_panic_runtime)]
|
||||
#![feature(nonnull_cast)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![feature(nonzero)]
|
||||
#![feature(num_bits_bytes)]
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// Ideally this would be revised to use no_std, but for now it serves
|
||||
// well enough to reproduce (and illustrate) the bug from #16687.
|
||||
|
||||
#![feature(heap_api, allocator_api, nonnull_cast)]
|
||||
#![feature(heap_api, allocator_api)]
|
||||
|
||||
use std::alloc::{Global, Alloc, Layout};
|
||||
use std::ptr::{self, NonNull};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue