rust/tests/ui/mem_replace_macro.rs

24 lines
374 B
Rust
Raw Normal View History

// aux-build:macro_rules.rs
#![warn(clippy::mem_replace_with_default)]
#[macro_use]
extern crate macro_rules;
use std::mem;
macro_rules! take {
($s:expr) => {
std::mem::replace($s, Default::default())
};
}
fn replace_with_default() {
let s = &mut String::from("foo");
take!(s);
take_external!(s);
}
fn main() {
replace_with_default();
}