@@ -9,7 +9,8 @@ use crate::ub_checks;
99/// 
1010/// (Normal `Range` code needs to handle degenerate ranges like `10..0`, 
1111///  which takes extra checks compared to only handling the canonical form.) 
12- #[ derive( Clone ,  Debug ,  PartialEq ,  Eq ) ]  
12+ #[ derive( Debug ,  Clone ) ]  
13+ #[ derive_const( Eq ,  PartialEq ) ]  
1314pub ( crate )  struct  IndexRange  { 
1415    start :  usize , 
1516    end :  usize , 
@@ -54,7 +55,7 @@ impl IndexRange {
5455    /// # Safety 
5556     /// - Can only be called when `start < end`, aka when `len > 0`. 
5657     #[ inline]  
57-     unsafe  fn  next_unchecked ( & mut  self )  -> usize  { 
58+     const   unsafe  fn  next_unchecked ( & mut  self )  -> usize  { 
5859        debug_assert ! ( self . start < self . end) ; 
5960
6061        let  value = self . start ; 
@@ -66,7 +67,7 @@ impl IndexRange {
6667    /// # Safety 
6768     /// - Can only be called when `start < end`, aka when `len > 0`. 
6869     #[ inline]  
69-     unsafe  fn  next_back_unchecked ( & mut  self )  -> usize  { 
70+     const   unsafe  fn  next_back_unchecked ( & mut  self )  -> usize  { 
7071        debug_assert ! ( self . start < self . end) ; 
7172
7273        // SAFETY: The range isn't empty, so this cannot overflow 
@@ -116,7 +117,7 @@ impl IndexRange {
116117    } 
117118
118119    #[ inline]  
119-     fn  assume_range ( & self )  { 
120+     const   fn  assume_range ( & self )  { 
120121        // SAFETY: This is the type invariant 
121122        unsafe  {  crate :: hint:: assert_unchecked ( self . start  <= self . end )  } 
122123    } 
0 commit comments