Skip to content

Commit

Permalink
StepBy<Range<{int <= usize}>> can be TrustedLen
Browse files Browse the repository at this point in the history
  • Loading branch information
the8472 committed Jun 25, 2023
1 parent f70a4b9 commit 8a72f35
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion library/core/src/iter/adapters/step_by.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::convert::TryFrom;
use crate::{
intrinsics,
iter::from_fn,
iter::{from_fn, TrustedLen},
ops::{Range, Try},
};

Expand Down Expand Up @@ -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<Range<$t>> {}
)*)
}

Expand Down

0 comments on commit 8a72f35

Please sign in to comment.