|
| 1 | +use crate::marker::Destruct; |
1 | 2 | use crate::ops::{ControlFlow, Try};
|
2 | 3 |
|
3 | 4 | /// An iterator able to yield elements from both ends.
|
@@ -37,6 +38,7 @@ use crate::ops::{ControlFlow, Try};
|
37 | 38 | /// ```
|
38 | 39 | #[stable(feature = "rust1", since = "1.0.0")]
|
39 | 40 | #[cfg_attr(not(test), rustc_diagnostic_item = "DoubleEndedIterator")]
|
| 41 | +#[const_trait] |
40 | 42 | pub trait DoubleEndedIterator: Iterator {
|
41 | 43 | /// Removes and returns an element from the end of the iterator.
|
42 | 44 | ///
|
@@ -131,7 +133,10 @@ pub trait DoubleEndedIterator: Iterator {
|
131 | 133 | /// [`Err(k)`]: Err
|
132 | 134 | #[inline]
|
133 | 135 | #[unstable(feature = "iter_advance_by", reason = "recently added", issue = "77404")]
|
134 |
| - fn advance_back_by(&mut self, n: usize) -> Result<(), usize> { |
| 136 | + fn advance_back_by(&mut self, n: usize) -> Result<(), usize> |
| 137 | + where |
| 138 | + Self::Item: ~const Destruct, |
| 139 | + { |
135 | 140 | for i in 0..n {
|
136 | 141 | self.next_back().ok_or(i)?;
|
137 | 142 | }
|
@@ -181,6 +186,7 @@ pub trait DoubleEndedIterator: Iterator {
|
181 | 186 | /// ```
|
182 | 187 | #[inline]
|
183 | 188 | #[stable(feature = "iter_nth_back", since = "1.37.0")]
|
| 189 | + #[rustc_do_not_const_check] |
184 | 190 | fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
|
185 | 191 | self.advance_back_by(n).ok()?;
|
186 | 192 | self.next_back()
|
@@ -218,6 +224,7 @@ pub trait DoubleEndedIterator: Iterator {
|
218 | 224 | /// ```
|
219 | 225 | #[inline]
|
220 | 226 | #[stable(feature = "iterator_try_fold", since = "1.27.0")]
|
| 227 | + #[rustc_do_not_const_check] |
221 | 228 | fn try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R
|
222 | 229 | where
|
223 | 230 | Self: Sized,
|
@@ -289,6 +296,7 @@ pub trait DoubleEndedIterator: Iterator {
|
289 | 296 | #[doc(alias = "foldr")]
|
290 | 297 | #[inline]
|
291 | 298 | #[stable(feature = "iter_rfold", since = "1.27.0")]
|
| 299 | + #[rustc_do_not_const_check] |
292 | 300 | fn rfold<B, F>(mut self, init: B, mut f: F) -> B
|
293 | 301 | where
|
294 | 302 | Self: Sized,
|
@@ -344,6 +352,7 @@ pub trait DoubleEndedIterator: Iterator {
|
344 | 352 | /// ```
|
345 | 353 | #[inline]
|
346 | 354 | #[stable(feature = "iter_rfind", since = "1.27.0")]
|
| 355 | + #[rustc_do_not_const_check] |
347 | 356 | fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item>
|
348 | 357 | where
|
349 | 358 | Self: Sized,
|
|
0 commit comments