File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ fn replace_with_default() {
30
30
let _ = std::mem::take(&mut s);
31
31
let s = &mut String::from("foo");
32
32
let _ = std::mem::take(s);
33
+ let _ = std::mem::take(s);
33
34
}
34
35
35
36
fn main() {
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ fn replace_with_default() {
30
30
let _ = std:: mem:: replace ( & mut s, String :: default ( ) ) ;
31
31
let s = & mut String :: from ( "foo" ) ;
32
32
let _ = std:: mem:: replace ( s, String :: default ( ) ) ;
33
+ let _ = std:: mem:: replace ( s, Default :: default ( ) ) ;
33
34
}
34
35
35
36
fn main ( ) {
Original file line number Diff line number Diff line change @@ -26,5 +26,11 @@ error: replacing a value of type `T` with `T::default()` is better expressed usi
26
26
LL | let _ = std::mem::replace(s, String::default());
27
27
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(s)`
28
28
29
- error: aborting due to 4 previous errors
29
+ error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
30
+ --> $DIR/mem_replace.rs:33:13
31
+ |
32
+ LL | let _ = std::mem::replace(s, Default::default());
33
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(s)`
34
+
35
+ error: aborting due to 5 previous errors
30
36
You can’t perform that action at this time.
0 commit comments