File tree 1 file changed +16
-8
lines changed
1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -665,10 +665,14 @@ macro_rules! iterator {
665
665
#[ inline]
666
666
fn next( & mut self ) -> Option <$elem> {
667
667
// could be implemented with slices, but this avoids bounds checks
668
- unsafe {
669
- if self . ptr == self . end {
670
- None
671
- } else {
668
+ if self . ptr == self . end {
669
+ None
670
+ } else {
671
+ unsafe {
672
+ if mem:: size_of:: <T >( ) != 0 {
673
+ :: intrinsics:: assume( !self . ptr. is_null( ) ) ;
674
+ :: intrinsics:: assume( !self . end. is_null( ) ) ;
675
+ }
672
676
let old = self . ptr;
673
677
self . ptr = slice_offset!( self . ptr, 1 ) ;
674
678
Some ( slice_ref!( old) )
@@ -706,11 +710,15 @@ macro_rules! iterator {
706
710
#[ inline]
707
711
fn next_back( & mut self ) -> Option <$elem> {
708
712
// could be implemented with slices, but this avoids bounds checks
709
- unsafe {
710
- if self . end == self . ptr {
711
- None
712
- } else {
713
+ if self . end == self . ptr {
714
+ None
715
+ } else {
716
+ unsafe {
713
717
self . end = slice_offset!( self . end, -1 ) ;
718
+ if mem:: size_of:: <T >( ) != 0 {
719
+ :: intrinsics:: assume( !self . ptr. is_null( ) ) ;
720
+ :: intrinsics:: assume( !self . end. is_null( ) ) ;
721
+ }
714
722
Some ( slice_ref!( self . end) )
715
723
}
716
724
}
You can’t perform that action at this time.
0 commit comments