From d748cd156f03c4becee849cec24029f368fb1f27 Mon Sep 17 00:00:00 2001 From: Hariettemaina Date: Mon, 22 May 2023 17:01:36 +0300 Subject: [PATCH] adding else condtions --- exercises/error_handling/errors1.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/error_handling/errors1.rs b/exercises/error_handling/errors1.rs index bcee9723..f3e4ec09 100644 --- a/exercises/error_handling/errors1.rs +++ b/exercises/error_handling/errors1.rs @@ -5,14 +5,14 @@ // construct to `Option` that can be used to express error conditions. Let's use it! // 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("`name` was empty; it must be nonempty.".into()) } else { - Some(format!("Hi! My name is {}", name)) + Ok(format!("Hi! My name is {}", name)) } }