Skip to content

Commit d41de3f

Browse files
authored
Add type invariant
1 parent c0927a7 commit d41de3f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

library/core/src/iter/adapters/step_by.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use safety::requires;
2-
31
use crate::intrinsics;
42
use crate::iter::{TrustedLen, TrustedRandomAccess, from_fn};
53
#[cfg(kani)]
64
use crate::kani;
75
use crate::num::NonZero;
86
use crate::ops::{Range, Try};
7+
use crate::ub_checks::Invariant;
98

109
/// An iterator for stepping iterators by a custom amount.
1110
///
@@ -33,6 +32,12 @@ pub struct StepBy<I> {
3332
first_take: bool,
3433
}
3534

35+
impl<I> Invariant for StepBy<I> {
36+
fn is_safe(&self) -> bool {
37+
step_minus_one < usize::MAX
38+
}
39+
}
40+
3641
impl<I> StepBy<I> {
3742
#[inline]
3843
pub(in crate::iter) fn new(iter: I, step: usize) -> StepBy<I> {

0 commit comments

Comments
 (0)