diff options
author | 2019-11-08 00:54:05 +0100 | |
---|---|---|
committer | 2019-11-08 00:54:05 +0100 | |
commit | b31a80f2c0ca198f1bf0206618654415d2da460e (patch) | |
tree | 2be68f0a5f5a7c8d5ba9734417de4c69a9f83857 | |
parent | 59ef7f074c67126dd8bd0ae9cbc82ce2a946258f (diff) | |
parent | 786ac31c0264b2525f28717d70ee4a66c9d2e581 (diff) | |
download | iced-b31a80f2c0ca198f1bf0206618654415d2da460e.tar.gz iced-b31a80f2c0ca198f1bf0206618654415d2da460e.tar.bz2 iced-b31a80f2c0ca198f1bf0206618654415d2da460e.zip |
Merge pull request #45 from memoryruins/smol-changes
Minor clean-up
-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) => { |