Summary
What we have essentially done here is build a program that accepts some command-line inputs, interacts with a file, and edits it depending on the command and data from that file. The data is fairly simple: a title and a status.
We could have done this all in the main
function with multiple match
statements and if
, else if
, and else
blocks. However, this is not scalable. Instead, we built structs that inherited other structs, which then implemented traits. We then packaged the construction of these structs into a factory enabling other files to use all that functionality in a single line of code.
We then built a processing interface so the command input, state, and struct could be processed, enabling us to stack on extra functionality and change the flow of the process with a few lines of code. Our main
function only has to focus on collecting the command-line arguments and coordinating when to call the module interfaces. We have now explored and utilized how Rust manages...