I wish `and_then` were named `flat_map` so badly.
Re:Announcing Rust 1.0 Beta
by Manishearth on Saturday April 04, 2015 @01:30AM
(#9320021)
We have `flat_map` for iterators. (`and_then` works for Options, which are basically nullables)
You can convert an Option to a zero-cost iterator and then use `flat_map` though.
Where familiarity comes in I believe is in what that line communicates to me: There might not be a file name (like having '/' as path), and that getting a string slice out of it might fail (the kind of string the platform uses for paths might not be UTF-8 compatible).
Plus, the unwrap()s tell me that whoever wrote the code considered it an assertion failure if one of those is happening.
I read a lot more Rust than I write, and it really helps that the code communicates a lot. And with knowing about OsString/OsStr beforehand, I only had to lookup when file_name() returns None, the rest is rather implicit by convention, or familiarity.