summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Hormiere <guillaume.hormiere@delair.aero>2020-07-22 22:26:19 +0200
committerGuillaume Hormiere <guillaume.hormiere@delair.aero>2020-07-22 22:26:19 +0200
commita0c57162b2026e37220e31a39d821c2a2e31cc51 (patch)
treee513dd085a7f0f3980fdce6965b75b87c0c361e7
parent9dfe454cd8bc816522446e7e3b9f45630c886112 (diff)
Use immutable vector instead of mutable one and change the message kind to Error
Apply code review
-rw-r--r--src/app/impl_self.rs6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs
index 38162ee..8a84cb2 100644
--- a/src/app/impl_self.rs
+++ b/src/app/impl_self.rs
@@ -34,10 +34,7 @@ impl App {
}
pub fn list_habit(&self) -> Vec<String> {
- let mut habits_names: Vec<String> = vec![];
- for h in self.habits.iter() {
- habits_names.push(h.name())
- }
+ let habits_names = self.habits.iter().map(|x| x.name()).collect::<Vec<_>>();
return habits_names;
}
@@ -49,6 +46,7 @@ impl App {
.count()
> 0
{
+ self.message.set_kind(MessageKind::Error);
self.message
.set_message(format!("Habit `{}` allready exist", h.name()))
} else {