This commit is contained in:
Tirth Patel 2024-04-11 15:30:47 -02:30
parent c29bf477b7
commit 294a568e3f

View File

@ -9,14 +9,13 @@
// Execute `rustlings hint errors1` or use the `hint` watch subcommand for a // Execute `rustlings hint errors1` or use the `hint` watch subcommand for a
// hint. // hint.
// I AM NOT DONE
pub fn generate_nametag_text(name: String) -> Option<String> { pub fn generate_nametag_text(name: String) -> Result<String, String> {
if name.is_empty() { if name.is_empty() {
// Empty names aren't allowed. // Empty names aren't allowed.
None Err(format!("`{}` was empty; it must be nonempty.", stringify!(name)))
} else { } else {
Some(format!("Hi! My name is {}", name)) Ok(format!("Hi! My name is {}", name))
} }
} }