/minigrep-rs

Less jacked version of grep written in Rust!

Primary LanguageRust

minigrep-rs

Minimal grep written in Rust! Follows chapter 10 of The Rust Book.

Usage

cargo run <word> <file>

Notes

  • Guideline for splitting the separate concerns (see more here) of a binary program when main starts getting large:
    • Split your program into a main.rs and a lib.rs and move your program’s logic to lib.rs.
    • As long as your command line parsing logic is small, it can remain in main.rs.
    • When the command line parsing logic starts getting complicated, extract it from main.rs and move it to lib.rs.
  • Call to panic! is more appropriate for a programming problem than a usage problem.
  • Test-driven development (TDD) process:
    1. Write a test that fails and run it to make sure it fails for the reason you expect.
    2. Write or modify just enough code to make the new test pass.
    3. Refactor the code you just added or changed and make sure the tests continue to pass.
    4. Repeat from step 1!