@@ -141,15 +141,15 @@ impl<T> SpecRangeSetup<T> for T {
141
141
142
142
/// Specialization trait to optimize `StepBy<Range<{integer}>>` iteration.
143
143
///
144
- /// # Correctness
144
+ /// # Safety
145
145
///
146
146
/// Technically this is safe to implement (look ma, no unsafe!), but in reality
147
147
/// a lot of unsafe code relies on ranges over integers being correct.
148
148
///
149
149
/// For correctness *all* public StepBy methods must be specialized
150
150
/// because `setup` drastically alters the meaning of the struct fields so that mixing
151
151
/// different implementations would lead to incorrect results.
152
- trait StepByImpl < I > {
152
+ unsafe trait StepByImpl < I > {
153
153
type Item ;
154
154
155
155
fn spec_next ( & mut self ) -> Option < Self :: Item > ;
@@ -172,13 +172,13 @@ trait StepByImpl<I> {
172
172
///
173
173
/// See also: `StepByImpl`
174
174
///
175
- /// # Correctness
175
+ /// # Safety
176
176
///
177
177
/// The specializations must be implemented together with `StepByImpl`
178
178
/// where applicable. I.e. if `StepBy` does support backwards iteration
179
179
/// for a given iterator and that is specialized for forward iteration then
180
180
/// it must also be specialized for backwards iteration.
181
- trait StepByBackImpl < I > {
181
+ unsafe trait StepByBackImpl < I > {
182
182
type Item ;
183
183
184
184
fn spec_next_back ( & mut self ) -> Option < Self :: Item >
@@ -201,7 +201,7 @@ trait StepByBackImpl<I> {
201
201
F : FnMut ( Acc , Self :: Item ) -> Acc ;
202
202
}
203
203
204
- impl < I : Iterator > StepByImpl < I > for StepBy < I > {
204
+ unsafe impl < I : Iterator > StepByImpl < I > for StepBy < I > {
205
205
type Item = I :: Item ;
206
206
207
207
#[ inline]
@@ -319,7 +319,7 @@ impl<I: Iterator> StepByImpl<I> for StepBy<I> {
319
319
}
320
320
}
321
321
322
- impl < I : DoubleEndedIterator + ExactSizeIterator > StepByBackImpl < I > for StepBy < I > {
322
+ unsafe impl < I : DoubleEndedIterator + ExactSizeIterator > StepByBackImpl < I > for StepBy < I > {
323
323
type Item = I :: Item ;
324
324
325
325
#[ inline]
@@ -416,7 +416,7 @@ macro_rules! spec_int_ranges {
416
416
}
417
417
}
418
418
419
- impl StepByImpl <Range <$t>> for StepBy <Range <$t>> {
419
+ unsafe impl StepByImpl <Range <$t>> for StepBy <Range <$t>> {
420
420
#[ inline]
421
421
fn spec_next( & mut self ) -> Option <$t> {
422
422
// if a step size larger than the type has been specified fall back to
@@ -497,7 +497,7 @@ macro_rules! spec_int_ranges_r {
497
497
( $( $t: ty) * ) => ( $(
498
498
const _: ( ) = assert!( usize :: BITS >= <$t>:: BITS ) ;
499
499
500
- impl StepByBackImpl <Range <$t>> for StepBy <Range <$t>> {
500
+ unsafe impl StepByBackImpl <Range <$t>> for StepBy <Range <$t>> {
501
501
502
502
#[ inline]
503
503
fn spec_next_back( & mut self ) -> Option <Self :: Item >
0 commit comments