Phase: Initial Design & Control Flow Diagramming (Chapter 6 Focus) Objective: Create a highly robust, error-handling calculator demonstrating Rust's core safety features.
This project is built under a 'Mission-Critical Standard' to achieve:
- Guaranteed Safety: Eliminate all possible runtime panics via explicit error handling.
- Structural Integrity (SRP): Decompose the application into single-responsibility units (I/O, Parsing, Calculation).
- Type Enforcement: Use Enums and Match statements to replace verbose conditional logic and enforce type integrity.
This program demonstrates mastery of the following fundamental Rust principles:
- Data Flow: Correct use of Borrowing (
&mut) to reuse a single input buffer efficiently, preventing memory churn. - Control Flow: Using Enums and the
matchexpression to manage application state and operation selection. - Structs/Methods: Grouping data and behavior using
structsandimplmethods. - Error Handling: Utilizing the
Resulttype and custom error messages (Chapter 9 preview) to avoid the use ofexpect()orpanic!().
The core operation will be modeled by an Enum to enforce mutual exclusivity:
enum Operation { Add(f64, f64), Subtract(f64, f64), ... }