rust-clippy/tests/ui/pathbuf_init_then_push.fixed
2024-07-21 14:22:48 +08:00

22 lines
484 B
Rust

#![warn(clippy::pathbuf_init_then_push)]
use std::path::PathBuf;
fn main() {
let mut path_buf = PathBuf::from("foo");
path_buf = PathBuf::from("foo").join("bar");
let bar = "bar";
path_buf = PathBuf::from("foo").join(bar);
let mut path_buf = PathBuf::from("foo").join("bar").join("buz");
let mut x = PathBuf::new();
println!("{}", x.display());
x.push("Duck");
let mut path_buf = PathBuf::new();
#[cfg(cats)]
path_buf.push("foo");
}