Stabilize iter::repeat_n
This commit is contained in:
parent
79611d90b6
commit
dfea11d620
@ -131,7 +131,6 @@
|
|||||||
#![feature(inplace_iteration)]
|
#![feature(inplace_iteration)]
|
||||||
#![feature(iter_advance_by)]
|
#![feature(iter_advance_by)]
|
||||||
#![feature(iter_next_chunk)]
|
#![feature(iter_next_chunk)]
|
||||||
#![feature(iter_repeat_n)]
|
|
||||||
#![feature(layout_for_ptr)]
|
#![feature(layout_for_ptr)]
|
||||||
#![feature(local_waker)]
|
#![feature(local_waker)]
|
||||||
#![feature(maybe_uninit_slice)]
|
#![feature(maybe_uninit_slice)]
|
||||||
|
@ -436,7 +436,7 @@ fn $fold<AAA, FFF>(mut self, init: AAA, fold: FFF) -> AAA
|
|||||||
pub use self::sources::{once_with, OnceWith};
|
pub use self::sources::{once_with, OnceWith};
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub use self::sources::{repeat, Repeat};
|
pub use self::sources::{repeat, Repeat};
|
||||||
#[unstable(feature = "iter_repeat_n", issue = "104434")]
|
#[stable(feature = "iter_repeat_n", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub use self::sources::{repeat_n, RepeatN};
|
pub use self::sources::{repeat_n, RepeatN};
|
||||||
#[stable(feature = "iterator_repeat_with", since = "1.28.0")]
|
#[stable(feature = "iterator_repeat_with", since = "1.28.0")]
|
||||||
pub use self::sources::{repeat_with, RepeatWith};
|
pub use self::sources::{repeat_with, RepeatWith};
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
pub use self::once_with::{once_with, OnceWith};
|
pub use self::once_with::{once_with, OnceWith};
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub use self::repeat::{repeat, Repeat};
|
pub use self::repeat::{repeat, Repeat};
|
||||||
#[unstable(feature = "iter_repeat_n", issue = "104434")]
|
#[stable(feature = "iter_repeat_n", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub use self::repeat_n::{repeat_n, RepeatN};
|
pub use self::repeat_n::{repeat_n, RepeatN};
|
||||||
#[stable(feature = "iterator_repeat_with", since = "1.28.0")]
|
#[stable(feature = "iterator_repeat_with", since = "1.28.0")]
|
||||||
pub use self::repeat_with::{repeat_with, RepeatWith};
|
pub use self::repeat_with::{repeat_with, RepeatWith};
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
/// Basic usage:
|
/// Basic usage:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(iter_repeat_n)]
|
|
||||||
/// use std::iter;
|
/// use std::iter;
|
||||||
///
|
///
|
||||||
/// // four of the number four:
|
/// // four of the number four:
|
||||||
@ -36,7 +35,6 @@
|
|||||||
/// For non-`Copy` types,
|
/// For non-`Copy` types,
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(iter_repeat_n)]
|
|
||||||
/// use std::iter;
|
/// use std::iter;
|
||||||
///
|
///
|
||||||
/// let v: Vec<i32> = Vec::with_capacity(123);
|
/// let v: Vec<i32> = Vec::with_capacity(123);
|
||||||
@ -58,7 +56,7 @@
|
|||||||
/// assert_eq!(None, it.next());
|
/// assert_eq!(None, it.next());
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[unstable(feature = "iter_repeat_n", issue = "104434")]
|
#[stable(feature = "iter_repeat_n", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub fn repeat_n<T: Clone>(element: T, count: usize) -> RepeatN<T> {
|
pub fn repeat_n<T: Clone>(element: T, count: usize) -> RepeatN<T> {
|
||||||
let mut element = ManuallyDrop::new(element);
|
let mut element = ManuallyDrop::new(element);
|
||||||
|
|
||||||
@ -77,7 +75,7 @@ pub fn repeat_n<T: Clone>(element: T, count: usize) -> RepeatN<T> {
|
|||||||
/// This `struct` is created by the [`repeat_n()`] function.
|
/// This `struct` is created by the [`repeat_n()`] function.
|
||||||
/// See its documentation for more.
|
/// See its documentation for more.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[unstable(feature = "iter_repeat_n", issue = "104434")]
|
#[stable(feature = "iter_repeat_n", since = "CURRENT_RUSTC_VERSION")]
|
||||||
pub struct RepeatN<A> {
|
pub struct RepeatN<A> {
|
||||||
count: usize,
|
count: usize,
|
||||||
// Invariant: has been dropped iff count == 0.
|
// Invariant: has been dropped iff count == 0.
|
||||||
@ -101,14 +99,14 @@ fn take_element(&mut self) -> Option<A> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "iter_repeat_n", issue = "104434")]
|
#[stable(feature = "iter_repeat_n", since = "CURRENT_RUSTC_VERSION")]
|
||||||
impl<A> Drop for RepeatN<A> {
|
impl<A> Drop for RepeatN<A> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.take_element();
|
self.take_element();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "iter_repeat_n", issue = "104434")]
|
#[stable(feature = "iter_repeat_n", since = "CURRENT_RUSTC_VERSION")]
|
||||||
impl<A: Clone> Iterator for RepeatN<A> {
|
impl<A: Clone> Iterator for RepeatN<A> {
|
||||||
type Item = A;
|
type Item = A;
|
||||||
|
|
||||||
@ -156,14 +154,14 @@ fn count(self) -> usize {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "iter_repeat_n", issue = "104434")]
|
#[stable(feature = "iter_repeat_n", since = "CURRENT_RUSTC_VERSION")]
|
||||||
impl<A: Clone> ExactSizeIterator for RepeatN<A> {
|
impl<A: Clone> ExactSizeIterator for RepeatN<A> {
|
||||||
fn len(&self) -> usize {
|
fn len(&self) -> usize {
|
||||||
self.count
|
self.count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "iter_repeat_n", issue = "104434")]
|
#[stable(feature = "iter_repeat_n", since = "CURRENT_RUSTC_VERSION")]
|
||||||
impl<A: Clone> DoubleEndedIterator for RepeatN<A> {
|
impl<A: Clone> DoubleEndedIterator for RepeatN<A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next_back(&mut self) -> Option<A> {
|
fn next_back(&mut self) -> Option<A> {
|
||||||
@ -181,12 +179,12 @@ fn nth_back(&mut self, n: usize) -> Option<A> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "iter_repeat_n", issue = "104434")]
|
#[stable(feature = "iter_repeat_n", since = "CURRENT_RUSTC_VERSION")]
|
||||||
impl<A: Clone> FusedIterator for RepeatN<A> {}
|
impl<A: Clone> FusedIterator for RepeatN<A> {}
|
||||||
|
|
||||||
#[unstable(feature = "trusted_len", issue = "37572")]
|
#[unstable(feature = "trusted_len", issue = "37572")]
|
||||||
unsafe impl<A: Clone> TrustedLen for RepeatN<A> {}
|
unsafe impl<A: Clone> TrustedLen for RepeatN<A> {}
|
||||||
#[unstable(feature = "trusted_len_next_unchecked", issue = "37572")]
|
#[stable(feature = "iter_repeat_n", since = "CURRENT_RUSTC_VERSION")]
|
||||||
impl<A: Clone> UncheckedIterator for RepeatN<A> {
|
impl<A: Clone> UncheckedIterator for RepeatN<A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn next_unchecked(&mut self) -> Self::Item {
|
unsafe fn next_unchecked(&mut self) -> Self::Item {
|
||||||
|
@ -73,7 +73,6 @@
|
|||||||
#![feature(iter_next_chunk)]
|
#![feature(iter_next_chunk)]
|
||||||
#![feature(iter_order_by)]
|
#![feature(iter_order_by)]
|
||||||
#![feature(iter_partition_in_place)]
|
#![feature(iter_partition_in_place)]
|
||||||
#![feature(iter_repeat_n)]
|
|
||||||
#![feature(iterator_try_collect)]
|
#![feature(iterator_try_collect)]
|
||||||
#![feature(iterator_try_reduce)]
|
#![feature(iterator_try_reduce)]
|
||||||
#![feature(layout_for_ptr)]
|
#![feature(layout_for_ptr)]
|
||||||
|
Loading…
Reference in New Issue
Block a user