Skip to content

Commit f74b74c

Browse files
committed
iter mut ExactSizeIterator
1 parent ab0c62a commit f74b74c

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

library/core/src/iter/range.rs

+24-6
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,9 @@ macro_rules! range_exact_iter_impl {
599599
($($t:ty)*) => ($(
600600
#[stable(feature = "rust1", since = "1.0.0")]
601601
impl ExactSizeIterator for RangeIter<$t> { }
602+
603+
#[stable(feature = "new_range", since = "1.0.0")]
604+
impl ExactSizeIterator for RangeIterMut<'_, $t> { }
602605
)*)
603606
}
604607

@@ -622,6 +625,9 @@ macro_rules! range_incl_exact_iter_impl {
622625
($($t:ty)*) => ($(
623626
#[stable(feature = "inclusive_range", since = "1.26.0")]
624627
impl ExactSizeIterator for RangeInclusiveIter<$t> { }
628+
629+
#[stable(feature = "new_range", since = "1.0.0")]
630+
impl ExactSizeIterator for RangeInclusiveIterMut<'_, $t> { }
625631
)*)
626632
}
627633

@@ -839,6 +845,10 @@ impl<'a, Idx: Step> Iterator for RangeIterMut<'a, Idx> {
839845

840846
out
841847
}
848+
849+
fn size_hint(&self) -> (usize, Option<usize>) {
850+
self.range.size_hint()
851+
}
842852
}
843853
#[stable(feature = "new_range", since = "1.0.0")]
844854
impl<'a, Idx: Step> DoubleEndedIterator for RangeIterMut<'a, Idx> {
@@ -953,6 +963,10 @@ impl<'a, Idx: Step> Iterator for RangeFromIterMut<'a, Idx> {
953963

954964
out
955965
}
966+
967+
fn size_hint(&self) -> (usize, Option<usize>) {
968+
self.range.size_hint()
969+
}
956970
}
957971

958972
impl<Idx: Step> ops::range::RangeFrom<Idx> {
@@ -1155,6 +1169,10 @@ impl<'a, Idx: Step> Iterator for RangeInclusiveIterMut<'a, Idx> {
11551169

11561170
out
11571171
}
1172+
1173+
fn size_hint(&self) -> (usize, Option<usize>) {
1174+
self.range.size_hint()
1175+
}
11581176
}
11591177
#[stable(feature = "new_range", since = "1.0.0")]
11601178
impl<'a, Idx: Step> DoubleEndedIterator for RangeInclusiveIterMut<'a, Idx> {
@@ -1494,7 +1512,7 @@ impl<Idx: Step> ops::range::$ty<Idx> {
14941512

14951513
/// Alias for `.iter_mut()`
14961514
///
1497-
/// See [`Iterator::iter_mut`]
1515+
/// See [`iter_mut`](Self::iter_mut)
14981516
#[stable(feature = "new_range", since = "1.0.0")]
14991517
#[deprecated(since = "1.0.0", note = "range-experiment-mut-self")]
15001518
pub fn by_ref(&mut self) -> <&mut Self as IntoIterator>::IntoIter {
@@ -1998,7 +2016,7 @@ impl<Idx: Step> ops::range::$ty<Idx> {
19982016

19992017
/// Shorthand for `.iter_mut().advance_back_by(...)`
20002018
///
2001-
/// See [`Iterator::advance_back_by`]
2019+
/// See [`DoubleEndedIterator::advance_back_by`]
20022020
#[unstable(feature = "iter_advance_by", reason = "recently added", issue = "77404")]
20032021
#[deprecated(since = "1.0.0", note = "range-experiment-mut-self")]
20042022
pub fn advance_back_by(&mut self, n: usize) -> Result<(), NonZeroUsize> {
@@ -2007,7 +2025,7 @@ impl<Idx: Step> ops::range::$ty<Idx> {
20072025

20082026
/// Shorthand for `.iter_mut().nth_back(...)`
20092027
///
2010-
/// See [`Iterator::nth_back`]
2028+
/// See [`DoubleEndedIterator::nth_back`]
20112029
#[stable(feature = "new_range", since = "1.0.0")]
20122030
#[deprecated(since = "1.0.0", note = "range-experiment-mut-self")]
20132031
pub fn nth_back(&mut self, n: usize) -> Option<Idx> {
@@ -2016,7 +2034,7 @@ impl<Idx: Step> ops::range::$ty<Idx> {
20162034

20172035
/// Shorthand for `.iter_mut().try_rfold(...)`
20182036
///
2019-
/// See [`Iterator::try_rfold`]
2037+
/// See [`DoubleEndedIterator::try_rfold`]
20202038
#[stable(feature = "new_range", since = "1.0.0")]
20212039
#[deprecated(since = "1.0.0", note = "range-experiment-mut-self")]
20222040
pub fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R
@@ -2029,7 +2047,7 @@ impl<Idx: Step> ops::range::$ty<Idx> {
20292047

20302048
/// Shorthand for `.into_iter().rfold(...)`
20312049
///
2032-
/// See [`Iterator::rfold`]
2050+
/// See [`DoubleEndedIterator::rfold`]
20332051
#[stable(feature = "new_range", since = "1.0.0")]
20342052
pub fn rfold<B, F>(self, init: B, f: F) -> B
20352053
where
@@ -2040,7 +2058,7 @@ impl<Idx: Step> ops::range::$ty<Idx> {
20402058

20412059
/// Shorthand for `.iter_mut().rfind(...)`
20422060
///
2043-
/// See [`Iterator::rfind`]
2061+
/// See [`DoubleEndedIterator::rfind`]
20442062
#[stable(feature = "new_range", since = "1.0.0")]
20452063
#[deprecated(since = "1.0.0", note = "range-experiment-mut-self")]
20462064
pub fn rfind<P>(&mut self, predicate: P) -> Option<Idx>

0 commit comments

Comments
 (0)