Auto merge of #60333 - Centril:stabilize-iterator-copied, r=varkor
Stabilize Iterator::copied in 1.36.0 Per https://github.com/rust-lang/rust/issues/57127#issuecomment-487289429. Closes https://github.com/rust-lang/rust/issues/57127. r? @varkor
This commit is contained in:
commit
5f0dc0e1ff
4 changed files with 9 additions and 11 deletions
|
@ -130,19 +130,20 @@ unsafe impl<I> TrustedLen for Rev<I>
|
|||
///
|
||||
/// [`copied`]: trait.Iterator.html#method.copied
|
||||
/// [`Iterator`]: trait.Iterator.html
|
||||
#[unstable(feature = "iter_copied", issue = "57127")]
|
||||
#[stable(feature = "iter_copied", since = "1.36.0")]
|
||||
#[must_use = "iterators are lazy and do nothing unless consumed"]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Copied<I> {
|
||||
it: I,
|
||||
}
|
||||
|
||||
impl<I> Copied<I> {
|
||||
pub(super) fn new(it: I) -> Copied<I> {
|
||||
Copied { it }
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "iter_copied", issue = "57127")]
|
||||
#[stable(feature = "iter_copied", since = "1.36.0")]
|
||||
impl<'a, I, T: 'a> Iterator for Copied<I>
|
||||
where I: Iterator<Item=&'a T>, T: Copy
|
||||
{
|
||||
|
@ -169,7 +170,7 @@ impl<'a, I, T: 'a> Iterator for Copied<I>
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "iter_copied", issue = "57127")]
|
||||
#[stable(feature = "iter_copied", since = "1.36.0")]
|
||||
impl<'a, I, T: 'a> DoubleEndedIterator for Copied<I>
|
||||
where I: DoubleEndedIterator<Item=&'a T>, T: Copy
|
||||
{
|
||||
|
@ -190,7 +191,7 @@ impl<'a, I, T: 'a> DoubleEndedIterator for Copied<I>
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "iter_copied", issue = "57127")]
|
||||
#[stable(feature = "iter_copied", since = "1.36.0")]
|
||||
impl<'a, I, T: 'a> ExactSizeIterator for Copied<I>
|
||||
where I: ExactSizeIterator<Item=&'a T>, T: Copy
|
||||
{
|
||||
|
@ -203,7 +204,7 @@ impl<'a, I, T: 'a> ExactSizeIterator for Copied<I>
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "iter_copied", issue = "57127")]
|
||||
#[stable(feature = "iter_copied", since = "1.36.0")]
|
||||
impl<'a, I, T: 'a> FusedIterator for Copied<I>
|
||||
where I: FusedIterator<Item=&'a T>, T: Copy
|
||||
{}
|
||||
|
@ -222,7 +223,7 @@ unsafe impl<'a, I, T: 'a> TrustedRandomAccess for Copied<I>
|
|||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "iter_copied", issue = "57127")]
|
||||
#[stable(feature = "iter_copied", since = "1.36.0")]
|
||||
unsafe impl<'a, I, T: 'a> TrustedLen for Copied<I>
|
||||
where I: TrustedLen<Item=&'a T>,
|
||||
T: Copy
|
||||
|
|
|
@ -352,7 +352,7 @@ pub use self::adapters::Cloned;
|
|||
pub use self::adapters::StepBy;
|
||||
#[stable(feature = "iterator_flatten", since = "1.29.0")]
|
||||
pub use self::adapters::Flatten;
|
||||
#[unstable(feature = "iter_copied", issue = "57127")]
|
||||
#[stable(feature = "iter_copied", since = "1.36.0")]
|
||||
pub use self::adapters::Copied;
|
||||
|
||||
pub(crate) use self::adapters::TrustedRandomAccess;
|
||||
|
|
|
@ -2206,8 +2206,6 @@ pub trait Iterator {
|
|||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(iter_copied)]
|
||||
///
|
||||
/// let a = [1, 2, 3];
|
||||
///
|
||||
/// let v_cloned: Vec<_> = a.iter().copied().collect();
|
||||
|
@ -2218,7 +2216,7 @@ pub trait Iterator {
|
|||
/// assert_eq!(v_cloned, vec![1, 2, 3]);
|
||||
/// assert_eq!(v_map, vec![1, 2, 3]);
|
||||
/// ```
|
||||
#[unstable(feature = "iter_copied", issue = "57127")]
|
||||
#[stable(feature = "iter_copied", since = "1.36.0")]
|
||||
fn copied<'a, T: 'a>(self) -> Copied<Self>
|
||||
where Self: Sized + Iterator<Item=&'a T>, T: Copy
|
||||
{
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#![feature(fmt_internals)]
|
||||
#![feature(hashmap_internals)]
|
||||
#![feature(is_sorted)]
|
||||
#![feature(iter_copied)]
|
||||
#![feature(iter_nth_back)]
|
||||
#![feature(iter_once_with)]
|
||||
#![feature(pattern)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue