@@ -581,10 +581,10 @@ impl<S: VecStorage<u8> + ?Sized> StringInner<S> {
581581 /// ```
582582 #[ inline]
583583 pub fn remove ( & mut self , index : usize ) -> char {
584- let ch = match self [ index..] . chars ( ) . next ( ) {
585- Some ( ch ) => ch ,
586- None => panic ! ( "cannot remove a char from the end of a string" ) ,
587- } ;
584+ let ch = self [ index..]
585+ . chars ( )
586+ . next ( )
587+ . unwrap_or_else ( || panic ! ( "cannot remove a char from the end of a string" ) ) ;
588588
589589 let next = index + ch. len_utf8 ( ) ;
590590 let len = self . len ( ) ;
@@ -632,7 +632,7 @@ impl<const N: usize> Default for String<N> {
632632impl < ' a , const N : usize > TryFrom < & ' a str > for String < N > {
633633 type Error = ( ) ;
634634 fn try_from ( s : & ' a str ) -> Result < Self , Self :: Error > {
635- let mut new = String :: new ( ) ;
635+ let mut new = Self :: new ( ) ;
636636 new. push_str ( s) ?;
637637 Ok ( new)
638638 }
@@ -642,15 +642,15 @@ impl<const N: usize> str::FromStr for String<N> {
642642 type Err = ( ) ;
643643
644644 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
645- let mut new = String :: new ( ) ;
645+ let mut new = Self :: new ( ) ;
646646 new. push_str ( s) ?;
647647 Ok ( new)
648648 }
649649}
650650
651651impl < const N : usize > iter:: FromIterator < char > for String < N > {
652652 fn from_iter < T : IntoIterator < Item = char > > ( iter : T ) -> Self {
653- let mut new = String :: new ( ) ;
653+ let mut new = Self :: new ( ) ;
654654 for c in iter {
655655 new. push ( c) . unwrap ( ) ;
656656 }
@@ -660,7 +660,7 @@ impl<const N: usize> iter::FromIterator<char> for String<N> {
660660
661661impl < ' a , const N : usize > iter:: FromIterator < & ' a char > for String < N > {
662662 fn from_iter < T : IntoIterator < Item = & ' a char > > ( iter : T ) -> Self {
663- let mut new = String :: new ( ) ;
663+ let mut new = Self :: new ( ) ;
664664 for c in iter {
665665 new. push ( * c) . unwrap ( ) ;
666666 }
@@ -670,7 +670,7 @@ impl<'a, const N: usize> iter::FromIterator<&'a char> for String<N> {
670670
671671impl < ' a , const N : usize > iter:: FromIterator < & ' a str > for String < N > {
672672 fn from_iter < T : IntoIterator < Item = & ' a str > > ( iter : T ) -> Self {
673- let mut new = String :: new ( ) ;
673+ let mut new = Self :: new ( ) ;
674674 for c in iter {
675675 new. push_str ( c) . unwrap ( ) ;
676676 }
@@ -782,7 +782,7 @@ impl<S: VecStorage<u8> + ?Sized> PartialEq<&str> for StringInner<S> {
782782impl < S : VecStorage < u8 > + ?Sized > PartialEq < StringInner < S > > for str {
783783 #[ inline]
784784 fn eq ( & self , other : & StringInner < S > ) -> bool {
785- str :: eq ( self , & other[ ..] )
785+ Self :: eq ( self , & other[ ..] )
786786 }
787787}
788788
0 commit comments