diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/color.rs | 12 | ||||
-rw-r--r-- | core/src/widget/text_input.rs | 11 |
2 files changed, 15 insertions, 8 deletions
diff --git a/core/src/color.rs b/core/src/color.rs index 79910dd8..150bd05b 100644 --- a/core/src/color.rs +++ b/core/src/color.rs @@ -44,3 +44,15 @@ impl Color { ] } } + +impl From<[f32; 3]> for Color { + fn from([r, g, b]: [f32; 3]) -> Self { + Color { r, g, b, a: 1.0 } + } +} + +impl From<[f32; 4]> for Color { + fn from([r, g, b, a]: [f32; 4]) -> Self { + Color { r, g, b, a } + } +} 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) { |