From 8a72f35234ce96c94a28b19f21086ad2095769da Mon Sep 17 00:00:00 2001 From: The 8472 Date: Sun, 25 Jun 2023 16:05:44 +0200 Subject: [PATCH] StepBy> can be TrustedLen --- library/core/src/iter/adapters/step_by.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/library/core/src/iter/adapters/step_by.rs b/library/core/src/iter/adapters/step_by.rs index 4e11ee87f93c..2458a13d987b 100644 --- a/library/core/src/iter/adapters/step_by.rs +++ b/library/core/src/iter/adapters/step_by.rs @@ -1,7 +1,7 @@ use crate::convert::TryFrom; use crate::{ intrinsics, - iter::from_fn, + iter::{from_fn, TrustedLen}, ops::{Range, Try}, }; @@ -484,6 +484,12 @@ macro_rules! spec_int_ranges { acc } } + + /// Safety: This macro is only applied to ranges over types <= usize + /// which means the inner length is guaranteed to fit into a usize and so + /// the outer length calculation won't encounter clamped values + #[unstable(feature = "trusted_len", issue = "37572")] + unsafe impl TrustedLen for StepBy> {} )*) }