Skip to content

Commit

Permalink
Stabilize Iterator::copied in 1.36.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Apr 27, 2019
1 parent d4a32d5 commit b71f8d4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
13 changes: 7 additions & 6 deletions src/libcore/iter/adapters/mod.rs
Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/iter/mod.rs
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/libcore/iter/traits/iterator.rs
Expand Up @@ -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();
Expand All @@ -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
{
Expand Down
1 change: 0 additions & 1 deletion src/libcore/tests/lib.rs
Expand Up @@ -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)]
Expand Down

0 comments on commit b71f8d4

Please sign in to comment.