@@ -2589,17 +2589,22 @@ where
25892589 }
25902590
25912591 #[ inline]
2592+ #[ track_caller]
25922593 fn index ( self , bits : & ' a BitSlice < T , O > ) -> Self :: Immut {
2593- self . get ( bits) . unwrap_or_else ( || {
2594- panic ! ( "index {} out of bounds: {}" , self , bits. len( ) )
2595- } )
2594+ match self . get ( bits) {
2595+ Some ( b) => b,
2596+ None => panic ! ( "index {} out of bounds: {}" , self , bits. len( ) )
2597+ }
25962598 }
25972599
25982600 #[ inline]
2601+ #[ track_caller]
25992602 fn index_mut ( self , bits : & ' a mut BitSlice < T , O > ) -> Self :: Mut {
26002603 let len = bits. len ( ) ;
2601- self . get_mut ( bits)
2602- . unwrap_or_else ( || panic ! ( "index {} out of bounds: {}" , self , len) )
2604+ match self . get_mut ( bits) {
2605+ Some ( b) => b,
2606+ None => panic ! ( "index {} out of bounds: {}" , self , len) ,
2607+ }
26032608 }
26042609}
26052610
@@ -2660,19 +2665,21 @@ macro_rules! range_impl {
26602665 fn index( self , bits: Self :: Immut ) -> Self :: Immut {
26612666 let r = self . clone( ) ;
26622667 let l = bits. len( ) ;
2663- self . get( bits) . unwrap_or_else( || {
2664- panic!( "range {:?} out of bounds: {}" , r, l)
2665- } )
2668+ match self . get( bits) {
2669+ Some ( b) => b,
2670+ None => panic!( "range {:?} out of bounds: {}" , r, l) ,
2671+ }
26662672 }
26672673
26682674 #[ inline]
26692675 #[ track_caller]
26702676 fn index_mut( self , bits: Self :: Mut ) -> Self :: Mut {
26712677 let r = self . clone( ) ;
26722678 let l = bits. len( ) ;
2673- self . get_mut( bits) . unwrap_or_else( || {
2674- panic!( "range {:?} out of bounds: {}" , r, l)
2675- } )
2679+ match self . get_mut( bits) {
2680+ Some ( b) => b,
2681+ None => panic!( "range {:?} out of bounds: {}" , r, l) ,
2682+ }
26762683 }
26772684 }
26782685 } ;
0 commit comments