From b9b008c1d4a730335bdc9d465b0fdf7869fb09d4 Mon Sep 17 00:00:00 2001 From: Hunter Kvalevog Date: Sun, 27 Sep 2026 12:11:32 -0500 Subject: rustlings: complete 13 --- rustlings/exercises/13_error_handling/errors1.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'rustlings/exercises/13_error_handling/errors1.rs') diff --git a/rustlings/exercises/13_error_handling/errors1.rs b/rustlings/exercises/13_error_handling/errors1.rs index e07fddc..b9b9bd5 100644 --- a/rustlings/exercises/13_error_handling/errors1.rs +++ b/rustlings/exercises/13_error_handling/errors1.rs @@ -4,12 +4,11 @@ // construct to `Option` that can be used to express error conditions. Change // the function signature and body to return `Result` instead // of `Option`. -fn generate_nametag_text(name: String) -> Option { +fn generate_nametag_text(name: String) -> Result { if name.is_empty() { - // Empty names aren't allowed - None + Err(String::from("Empty names aren't allowed")) } else { - Some(format!("Hi! My name is {name}")) + Ok(format!("Hi! My name is {name}")) } } -- cgit v1.2.3