@@ -195,14 +195,10 @@ impl<B: ?Sized + ToOwned> Clone for Cow<'_, B> {
195195 }
196196
197197 fn clone_from ( & mut self , source : & Self ) {
198- if let Owned ( ref mut dest) = * self {
199- if let Owned ( ref o) = * source {
200- o. borrow ( ) . clone_into ( dest) ;
201- return ;
202- }
198+ match ( self , source) {
199+ ( & mut Owned ( ref mut dest) , & Owned ( ref o) ) => o. borrow ( ) . clone_into ( dest) ,
200+ ( t, s) => * t = s. clone ( ) ,
203201 }
204-
205- * self = source. clone ( ) ;
206202 }
207203}
208204
@@ -449,9 +445,7 @@ impl<'a> AddAssign<&'a str> for Cow<'a, str> {
449445 fn add_assign ( & mut self , rhs : & ' a str ) {
450446 if self . is_empty ( ) {
451447 * self = Cow :: Borrowed ( rhs)
452- } else if rhs. is_empty ( ) {
453- return ;
454- } else {
448+ } else if !rhs. is_empty ( ) {
455449 if let Cow :: Borrowed ( lhs) = * self {
456450 let mut s = String :: with_capacity ( lhs. len ( ) + rhs. len ( ) ) ;
457451 s. push_str ( lhs) ;
@@ -467,9 +461,7 @@ impl<'a> AddAssign<Cow<'a, str>> for Cow<'a, str> {
467461 fn add_assign ( & mut self , rhs : Cow < ' a , str > ) {
468462 if self . is_empty ( ) {
469463 * self = rhs
470- } else if rhs. is_empty ( ) {
471- return ;
472- } else {
464+ } else if !rhs. is_empty ( ) {
473465 if let Cow :: Borrowed ( lhs) = * self {
474466 let mut s = String :: with_capacity ( lhs. len ( ) + rhs. len ( ) ) ;
475467 s. push_str ( lhs) ;
0 commit comments