← BackProject · 10
minigrep
RustGITHUB ↗
- Built from the minigrep project in The Rust Programming Language. The goal wasn't to ship a grep replacement; it was to internalize idiomatic Rust before reaching for external crates, by building something small enough to hold in your head entirely.
- Implements case-sensitive and case-insensitive pattern matching across arbitrary text files. Search mode is controlled via the CASE_INSENSITIVE environment variable, keeping the CLI interface clean and composable with shell scripts.
- Error handling uses Result throughout and propagates up the call stack with context. No panics in library code; only at the binary entry point, where the error message is formatted for the user. Library code surfaces errors, binary code decides what to do with them.
- Configuration is parsed into a typed Config struct at startup: file path, query string, and search mode are validated before any file I/O happens. Invalid usage surfaces early with a clear message.
- Unit tests cover the core search functions directly without filesystem fixtures: fast to run, easy to reason about. A concrete example of the Rust convention of keeping logic in library code and keeping the binary thin.
Tech Stack
RUST