diff options
-rw-r--r-- | core/src/widget/text_input.rs | 11 | ||||
-rw-r--r-- | examples/todos.rs | 2 |
2 files changed, 4 insertions, 9 deletions
diff --git a/core/src/widget/text_input.rs b/core/src/widget/text_input.rs index e5d6b70d..9c7f4bc8 100644 --- a/core/src/widget/text_input.rs +++ b/core/src/widget/text_input.rs @@ -125,17 +125,12 @@ impl Value { } pub fn until(&self, index: usize) -> Self { - Self(self.0[..index.min(self.len())].iter().cloned().collect()) + Self(self.0[..index.min(self.len())].to_vec()) } pub fn to_string(&self) -> String { - let mut string = String::new(); - - for c in self.0.iter() { - string.push(*c); - } - - string + use std::iter::FromIterator; + String::from_iter(self.0.iter()) } pub fn insert(&mut self, index: usize, c: char) { diff --git a/examples/todos.rs b/examples/todos.rs index 9581262a..2ebbcc7c 100644 --- a/examples/todos.rs +++ b/examples/todos.rs @@ -33,7 +33,7 @@ impl Application for Todos { Message::CreateTask => { if !self.input_value.is_empty() { self.tasks.push(Task::new(self.input_value.clone())); - self.input_value = String::new(); + self.input_value.clear(); } } Message::TaskChanged(i, completed) => { |