summaryrefslogtreecommitdiff
path: root/exercises/error_handling/errors1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'exercises/error_handling/errors1.rs')
-rw-r--r--exercises/error_handling/errors1.rs6
1 files 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<String> {
- 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))
}
}