Misunderstanding of PathBuf:push

⚓ Rust    📅 2025-06-24    👤 surdeus    👁️ 6      

surdeus

Warning

This post was published 49 days ago. The information described in this article may have changed.

The situation:

let mut p = PathBuf::from("/var");
p.push("/");
println!("{}", p.to_string_lossy()); // ?

Now, when I converting this path to the string type, it has / path (not /var as expected)

5 posts - 3 participants

Read full topic

🏷️ rust_feed