From 294a568e3f4f72aaf12e917f5ff4f7dc6de6e07d Mon Sep 17 00:00:00 2001 From: Tirth Patel Date: Thu, 11 Apr 2024 15:30:47 -0230 Subject: [PATCH] error1 --- exercises/13_error_handling/errors1.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/exercises/13_error_handling/errors1.rs b/exercises/13_error_handling/errors1.rs index 0ba59a57..cecc8e53 100644 --- a/exercises/13_error_handling/errors1.rs +++ b/exercises/13_error_handling/errors1.rs @@ -9,14 +9,13 @@ // Execute `rustlings hint errors1` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE -pub fn generate_nametag_text(name: String) -> Option { +pub fn generate_nametag_text(name: String) -> Result { if name.is_empty() { // Empty names aren't allowed. - None + Err(format!("`{}` was empty; it must be nonempty.", stringify!(name))) } else { - Some(format!("Hi! My name is {}", name)) + Ok(format!("Hi! My name is {}", name)) } }