Opening & reading files
The primary function that will contain the logic of our Markdown compiler is
parse_markdown_file()
, which takes a single argument: a string slice (&str
)
that corresponds to the Markdown file we want to create.
Let’s go ahead and create that dummy file right now. Copy all of the below text
into a new file called test.md
, and save it in the root of your Rust project.
The root of your Rust project also contains the manifest file (Cargo.toml
), so
just make sure test.md
and Cargo.toml
are in the same directory.
If you would rather just download test.md
directly, you can right-click and
save a copy via this link
|
|
As you can see, one of my most endearing qualities is my humble modesty.
With test.md
in the root of our project folder, we now have an actual file to
open and read from.