Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor clean-up #45

Merged
merged 2 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions core/src/widget/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to anyone looking in from the changelog: this could have been self.0.iter().collect() :)
micro-refactoring intensifies

}

pub fn insert(&mut self, index: usize, c: char) {
Expand Down
2 changes: 1 addition & 1 deletion examples/todos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down