g1t · merged · 11 entries · 3 tool calls
What happened
- Running on Claude Sonnet 5.5.
Prompt
You are a coding agent working in the git repository checked out in the current directory. Issue #4: Say goodbye too A `farewell(name)` next to `greeting(name)` would let other tools reuse this crate for both ends of a conversation. It should return `Goodbye, <name>!`. These commands must pass when you are done. Run them if the tools are installed: - cargo test Make the change and keep it focused on the issue. Commit your work with a clear message. Do not push; that is done for you. Finish with a short summary of what you changed and why. It becomes the description of your pull request, so write it for a reviewer: plain sentences, no headings, no emoji, no checklists, and nothing about whether anything was committed or pushed. Say what you did not verify.
- Bash
ls && cat src/lib.rs I'll mirror greeting's name handling (trim, fall back to "world") for consistency.
- Bash
python3 - <<'E' p='src/lib.rs' s=open(p).read() s=s.replace('''#[cfg(test)]''','''/// The farewell for `name`. pub fn farewell(name: &str) -> String { let trimmed = name.trim(); let display_name = if trimmed.is_empty() { "world" } else { trimmed }; format!("Goodbye, {display_name}!") } #[cfg(test)]''',1) s=s.rstrip()[:-1]+''' #[test] fn says_goodbye_by_name() { assert_eq!(farewell("Ada"), "Goodbye, Ada!"); } #[test] fn says_goodbye_to_world_when_blank() { assert_eq!(farewell(" "), "Goodbye, world!"); } #[test] fn farewell_trims_whitespace() { assert_eq!(farewell(" Ada "), "Goodbye, Ada!"); } } ''' open(p,'w').write(s) E cargo test 2>&1 | tail -5; git commit -qam "Add farewell function alongside greeting" && echo ok - Bash
cargo test 2>&1 | grep "test result" I added `farewell(name)` to `src/lib.rs`, next to `greeting`. It returns `Goodbye, <name>!`. The issue only specified the plain case. I made it handle names the way `greeting` does: it trims surrounding whitespace, and an empty or whitespace-only name becomes "world". So `farewell("")` returns `Goodbye, world!`. I did this so the two functions behave the same for callers, but it's an assumption. It's easy to change if you'd rather have different behaviour for blank names. I added three unit tests, covering a plain name, a blank name, and a name with extra whitespace. `cargo test` passes, 7 tests in all. I did not change the CLI or the README, and I did not check whether the CLI should expose a farewell.
- Pushed cfd8ba0f3f98.