Processing files is a daily task and sometimes—depending on the programming language—unreasonably hard. The Rust project teams have taken care of that problem and provide an easy-to-use API to access files. Let's dive right in.
Writing to and reading from files
Getting ready
First, create a new project using cargo new file-stuff. Now, to work with files, we need a text file to read and process. Lorem Ipsum (https://www.lipsum.com/) is a popular dummy text that can be generated on a large scale, so to proceed with the recipe, generate a few (200) paragraphs with this generator and save the text in a file called lorem.txt in the root directory.
Finish your preparations by opening the project directory in...