Post #3497801
2026-06-30 20:19 UTC
intuition check: what would you expect this Rust snippet to print?
```
use itertools::Itertools;
fn main() {
let p = std::path::Path::new("/a/b/c");
let s = p.components().map(|c| c.as_os_str().to_string_lossy()).join("/");
println!("s={s:?}");
}
```
Replies (2)
-
@yossarian@infosec.exchange 2026-06-30 20:27
spoiler here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=dc2f6e9480393e0a6fe7c1f8ceede5a8
-
@migratory@jorts.horse 2026-06-30 20:25
@yossarian@infosec.exchange I don't think a "component" of a path is a precisely defined thing, but my initial intuition would be "a/b/c"