-
Book Overview & Buying
-
Table Of Contents
Rust for C++ Developers
By :
Before getting into the meat of Rust's I/O handling, we're going to explore a few topics that will help lay the foundations needed for working with files. In this section, we'll investigate Rust's filesystem path abstraction, learn how to handle errors idiomatically, and discover a handful of useful functions that vastly simplify the task of reading files.
Unfortunately, the most popular operating systems all have slight differences in the way they handle filesystem paths, meaning that we need an abstraction to handle those differences. Here, Rust has come to our rescue with the std::path module. This module implements a set of types and an API to deal with filesystem paths in a way that is as cross-platform as possible while being unobtrusive to the programmer.
What are the differences we're trying to abstract away? First, different platforms use different directory separators. Some platforms use a forward...