@@ -195,14 +195,10 @@ impl<B: ?Sized + ToOwned> Clone for Cow<'_, B> {
195
195
}
196
196
197
197
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 ( ) ,
203
201
}
204
-
205
- * self = source. clone ( ) ;
206
202
}
207
203
}
208
204
@@ -449,9 +445,7 @@ impl<'a> AddAssign<&'a str> for Cow<'a, str> {
449
445
fn add_assign ( & mut self , rhs : & ' a str ) {
450
446
if self . is_empty ( ) {
451
447
* self = Cow :: Borrowed ( rhs)
452
- } else if rhs. is_empty ( ) {
453
- return ;
454
- } else {
448
+ } else if !rhs. is_empty ( ) {
455
449
if let Cow :: Borrowed ( lhs) = * self {
456
450
let mut s = String :: with_capacity ( lhs. len ( ) + rhs. len ( ) ) ;
457
451
s. push_str ( lhs) ;
@@ -467,9 +461,7 @@ impl<'a> AddAssign<Cow<'a, str>> for Cow<'a, str> {
467
461
fn add_assign ( & mut self , rhs : Cow < ' a , str > ) {
468
462
if self . is_empty ( ) {
469
463
* self = rhs
470
- } else if rhs. is_empty ( ) {
471
- return ;
472
- } else {
464
+ } else if !rhs. is_empty ( ) {
473
465
if let Cow :: Borrowed ( lhs) = * self {
474
466
let mut s = String :: with_capacity ( lhs. len ( ) + rhs. len ( ) ) ;
475
467
s. push_str ( lhs) ;
0 commit comments