Conversation
There was a problem hiding this comment.
Pull request overview
This PR submits Week 2 tasks, including a Day 3 “User Input” Rust CLI exercise (power options) and an additional Day 5 expense-tracker CLI with basic CRUD and file saving.
Changes:
- Added Day 3 Rust CLI that parses a user-entered power option and prints the corresponding action.
- Added Day 5 Rust expense tracker CLI with
add/view/update/deleteand persistence to a text file. - Added Cargo project scaffolding (
Cargo.toml,Cargo.lock,.gitignore) for both submissions.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 18 comments.
Show a summary per file
| File | Description |
|---|---|
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/stephen_expences.txt | Sample/generated saved output for the expense tracker. |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/src/tracker.rs | Implements ExpenseTracker storage and file saving. |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/src/main.rs | CLI menu + user input handling for expense tracker. |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/src/expense.rs | Defines Expense and TransactionType. |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/Cargo.toml | Cargo manifest for the Day 5 submission. |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/Cargo.lock | Cargo lockfile for the Day 5 submission. |
| submissions/week-2/day-5/Stephen-Ngozi-Merkle-Tree/.gitignore | Ignores Rust build output (target). |
| submissions/week-2/day-3/Stephen-Ngozi-User-Input/src/main.rs | Day 3 CLI that maps user input to an enum and prints an action. |
| submissions/week-2/day-3/Stephen-Ngozi-User-Input/Cargo.toml | Cargo manifest for the Day 3 submission. |
| submissions/week-2/day-3/Stephen-Ngozi-User-Input/Cargo.lock | Cargo lockfile for the Day 3 submission. |
| submissions/week-2/day-3/Stephen-Ngozi-User-Input/.gitignore | Ignores Rust build output (target). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| let new_expense = tracker.add(name, amount, tx_type); | ||
| println!(" Expense added successfully!"); | ||
| println!("ID: {}, Name: {}, Amount: ${:.2}, Type: {:?}", |
There was a problem hiding this comment.
This prints amount with $ here, but other flows (view/update) print Naria... for the amount. Pick one currency/format and keep it consistent across commands.
| println!("ID: {}, Name: {}, Amount: ${:.2}, Type: {:?}", | |
| println!("ID: {}, Name: {}, Amount: Naria{:.2}, Type: {:?}", |
| println!("All Expenses"); | ||
| for expense in expenses { | ||
| println!("ID: {} | Name: {} | Amount: Naria{:.2} | Type: {:?}", | ||
| expense.id, expense.name, expense.amount, expense.tx_type); | ||
| } |
There was a problem hiding this comment.
This prints amount with Naria..., but the add flow prints $.... Pick one currency/format and keep it consistent across commands.
| if tracker.update(id, amount, tx_type){ | ||
| println!("Expense Updated Successfu"); | ||
|
|
There was a problem hiding this comment.
If tracker.update(...) returns false (ID not found), nothing is printed, so the user gets no feedback. Add an else branch to print a “not found” message.
| mod expense; | ||
| mod tracker; | ||
|
|
There was a problem hiding this comment.
The PR metadata/title is for “Week 2 Day 3”, but this PR also adds a full Day 5 submission under submissions/week-2/day-5/.... If Day 5 work is intended, update the PR title/description; otherwise split into separate PRs.
| }else { | ||
| println!("Expense with ID {} not found!", id); | ||
|
|
||
| } |
There was a problem hiding this comment.
After tracker.update(...) succeeds, the follow-up tracker.values.get(&id) should always return Some, making the else branch effectively unreachable. Consider having update return the updated expense (or Option<&Expense>) to avoid a second lookup and dead code.
| }else { | |
| println!("Expense with ID {} not found!", id); | |
| } | |
| } | |
| } else { | |
| println!("Expense with ID {} not found!", id); |
| ID: 2, Name: Beans, Amount: 5000.00, Type: Credit | ||
| ID: 1, Name: Rice, Amount: 20000.00, Type: Credit |
There was a problem hiding this comment.
stephen_expences.txt looks like a runtime-generated output file (it’s created by save_to_file). Committing generated state makes future PRs noisy and can lead to merge conflicts; consider removing it from the submission and/or adding it to .gitignore (or writing under target//a dedicated data/ directory that is ignored).
| @@ -0,0 +1,6 @@ | |||
| [package] | |||
| name = "Stephen-Ngozi-Merkle-Tree" | |||
There was a problem hiding this comment.
Cargo package names with uppercase letters (e.g., Stephen-Ngozi-Merkle-Tree) can produce warnings and are not accepted on crates.io. Consider using a lowercase, kebab-case name (e.g., stephen-ngozi-merkle-tree).
| name = "Stephen-Ngozi-Merkle-Tree" | |
| name = "stephen-ngozi-merkle-tree" |
| }; | ||
|
|
||
| if tracker.update(id, amount, tx_type){ | ||
| println!("Expense Updated Successfu"); |
There was a problem hiding this comment.
Typo in success message: Successfu should be Successful.
| println!("Expense Updated Successfu"); | |
| println!("Expense Updated Successful"); |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Task Submission PR
Student Info:
Task Details:
Checklist Before Submitting:
Additional Comments:
If any, mention here.