Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions library/core/src/iter/traits/double_ended.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::marker::Destruct;
use crate::num::NonZero;
use crate::ops::{ControlFlow, Try};

Expand Down Expand Up @@ -38,7 +39,8 @@ use crate::ops::{ControlFlow, Try};
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "DoubleEndedIterator"]
pub trait DoubleEndedIterator: Iterator {
#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
pub const trait DoubleEndedIterator: [const] Iterator {
/// Removes and returns an element from the end of the iterator.
///
/// Returns `None` when there are no more elements.
Expand Down Expand Up @@ -135,6 +137,7 @@ pub trait DoubleEndedIterator: Iterator {
/// [`Err(k)`]: Err
#[inline]
#[unstable(feature = "iter_advance_by", issue = "77404")]
#[rustc_non_const_trait_method]
fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>> {
for i in 0..n {
if self.next_back().is_none() {
Expand Down Expand Up @@ -188,6 +191,7 @@ pub trait DoubleEndedIterator: Iterator {
/// ```
#[inline]
#[stable(feature = "iter_nth_back", since = "1.37.0")]
#[rustc_non_const_trait_method]
fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
if self.advance_back_by(n).is_err() {
return None;
Expand Down Expand Up @@ -230,8 +234,8 @@ pub trait DoubleEndedIterator: Iterator {
fn try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R
where
Self: Sized,
F: FnMut(B, Self::Item) -> R,
R: Try<Output = B>,
F: [const] FnMut(B, Self::Item) -> R + [const] Destruct,
R: [const] Try<Output = B>,
{
let mut accum = init;
while let Some(x) = self.next_back() {
Expand Down Expand Up @@ -300,8 +304,8 @@ pub trait DoubleEndedIterator: Iterator {
#[stable(feature = "iter_rfold", since = "1.27.0")]
fn rfold<B, F>(mut self, init: B, mut f: F) -> B
where
Self: Sized,
F: FnMut(B, Self::Item) -> B,
Self: Sized + [const] Destruct,
F: [const] FnMut(B, Self::Item) -> B + [const] Destruct,
{
let mut accum = init;
while let Some(x) = self.next_back() {
Expand Down Expand Up @@ -363,6 +367,7 @@ pub trait DoubleEndedIterator: Iterator {
/// ```
#[inline]
#[stable(feature = "iter_rfind", since = "1.27.0")]
#[rustc_non_const_trait_method]
fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item>
where
Self: Sized,
Expand Down
Loading