> The design of a path abstraction is surprisingly hard. Paths work
> radically differently on different platforms, so providing a
> cross-platform abstraction is challenging. On some platforms, paths
> are not required to be in Unicode, posing ergonomic and semantic
> difficulties for a Rust API. These difficulties are compounded if one
> also tries to provide efficient path manipulation that does not, for
> example, require extraneous copying. And, of course, the API should
> be easy and pleasant to use.
So, in this case, you have to call `file_name` to get the filename, but that returns an `Option`, since it might not be a file, it could be a directory. The `unwrap` says "crash if it's not a filename." You then have an `OsStr`, which is a string type that handles the kinds of cross-platform issues alluded to in the above paragraph. `to_str` will then attempt to turn it into a `&str`, but because `&str` must be unicode, if the conversion fails, it _also_ returns an Option, which is the last unwrap.In systems programming, details matter. As such, our stdlib APIs try to expose those details. I expect some people will write higher-level abstractions that hide all this if you don't care as much.
Tradeoffs tradeoffs tradeoffs...