mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-05 02:50:32 +00:00
21 lines
359 B
Rust
21 lines
359 B
Rust
// aux-build:macro_rules.rs
|
|
#![warn(clippy::mem_replace_with_default)]
|
|
|
|
#[macro_use]
|
|
extern crate macro_rules;
|
|
|
|
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();
|
|
}
|