From 582320aded8a9369f8b5a959419f04ea6d3f5b04 Mon Sep 17 00:00:00 2001 From: Steven nguyen Date: Tue, 8 Feb 2022 17:46:22 -0600 Subject: [PATCH] chore(errors1): use `is_empty()` instead of `len() > 0` more idiomatic according to clippy --- exercises/error_handling/errors1.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/error_handling/errors1.rs b/exercises/error_handling/errors1.rs index c417fb2..1a2a857 100644 --- a/exercises/error_handling/errors1.rs +++ b/exercises/error_handling/errors1.rs @@ -8,11 +8,11 @@ // I AM NOT DONE pub fn generate_nametag_text(name: String) -> Option { - if name.len() > 0 { - Some(format!("Hi! My name is {}", name)) - } else { + if name.is_empty() { // Empty names aren't allowed. None + } else { + Some(format!("Hi! My name is {}", name)) } }