diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index 8d0b2b9f55c9..2bd0380bad60 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs @@ -655,8 +655,13 @@ fn nth_back(&mut self, n: usize) -> Option { } } -#[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl TrustedLen for ops::Range {} +macro_rules! impl_trusted_len_for_range { + ($($type:ty)*) => {$( + #[unstable(feature = "trusted_len", issue = "37572")] + unsafe impl TrustedLen for ops::Range<$type> {} + )*} +} +impl_trusted_len_for_range![char i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize]; #[stable(feature = "fused", since = "1.26.0")] impl FusedIterator for ops::Range {} @@ -687,8 +692,13 @@ fn nth(&mut self, n: usize) -> Option { #[stable(feature = "fused", since = "1.26.0")] impl FusedIterator for ops::RangeFrom {} -#[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl TrustedLen for ops::RangeFrom {} +macro_rules! impl_trusted_len_for_range_from { + ($($type:ty)*) => {$( + #[unstable(feature = "trusted_len", issue = "37572")] + unsafe impl TrustedLen for ops::RangeFrom<$type> {} + )*} +} +impl_trusted_len_for_range_from![char i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize]; #[stable(feature = "inclusive_range", since = "1.26.0")] impl Iterator for ops::RangeInclusive { @@ -899,8 +909,13 @@ fn ok(mut f: impl FnMut(B, T) -> B) -> impl FnMut(B, T) -> Result { } } -#[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl TrustedLen for ops::RangeInclusive {} +macro_rules! impl_trusted_len_for_range_inclusive { + ($($type:ty)*) => {$( + #[unstable(feature = "trusted_len", issue = "37572")] + unsafe impl TrustedLen for ops::RangeInclusive<$type> {} + )*} +} +impl_trusted_len_for_range_inclusive![char i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize]; #[stable(feature = "fused", since = "1.26.0")] impl FusedIterator for ops::RangeInclusive {}