g1t

Greets people from the command line. The sample repository for g1t.

A blank name greets nobody #6

Closedsyntaqx wants to merge into maing1t-agenton g1t
For issueA blank name greets nobody#11 of 2 pull requests

Closed because #5 was merged for this issue instead.

Summary

Fixed the greeting function to properly handle empty and whitespace-only names. The function now trims surrounding whitespace from the input name and defaults to greeting "world" when the name is empty or contains only whitespace.

Changes:

  • Modified greeting() in src/lib.rs to trim the input and check if it's empty
  • Added three new tests: one for empty strings, one for whitespace-only strings, and one to verify trimming of surrounding whitespace
  • All existing and new tests pass

The issue where hello "" printed Hello, ! and hello " " printed Hello, ! is now resolved—both now correctly print Hello, world!

Sign in to comment.