summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authorSteven nguyen <nguyeste008@students.garlandisd.net>2022-02-08 17:46:22 -0600
committermokou <mokou@fastmail.com>2022-07-14 17:55:07 +0200
commit582320aded8a9369f8b5a959419f04ea6d3f5b04 (patch)
treed6e38ae6634d75122bacace7ab86d07362f51c61 /exercises
parentb71feed82464f476611765e8621b32e615b5dddc (diff)
chore(errors1): use `is_empty()` instead of `len() > 0`
more idiomatic according to clippy
Diffstat (limited to 'exercises')
-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))
}
}