diff options
author | 2019-11-29 21:24:52 -0500 | |
---|---|---|
committer | 2019-11-29 21:24:52 -0500 | |
commit | 267e242238fab0aba14fb4c2e27269ce3a3e3951 (patch) | |
tree | 6957be383f221ecc444ac50cdcbdfd45f6374349 /native/src/widget/text_input.rs | |
parent | 811d8b90d71c26100f0933217f5474e090fbf17c (diff) | |
download | iced-267e242238fab0aba14fb4c2e27269ce3a3e3951.tar.gz iced-267e242238fab0aba14fb4c2e27269ce3a3e3951.tar.bz2 iced-267e242238fab0aba14fb4c2e27269ce3a3e3951.zip |
Make many functions `const`
The point is to set up repeated components or boilerplate before their
use sites.
The majority of these make sense as `const`. However, some functions
such as those regarding state may not make sense as `const`.
Diffstat (limited to 'native/src/widget/text_input.rs')
-rw-r--r-- | native/src/widget/text_input.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index f97ed424..0246f0d5 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -326,14 +326,17 @@ impl State { /// Creates a new [`State`], representing an unfocused [`TextInput`]. /// /// [`State`]: struct.State.html - pub fn new() -> Self { - Self::default() + pub const fn new() -> Self { + Self { + is_focused: false, + cursor_position: 0, + } } /// Creates a new [`State`], representing a focused [`TextInput`]. /// /// [`State`]: struct.State.html - pub fn focused() -> Self { + pub const fn focused() -> Self { use std::usize; Self { @@ -345,7 +348,7 @@ impl State { /// Returns whether the [`TextInput`] is currently focused or not. /// /// [`TextInput`]: struct.TextInput.html - pub fn is_focused(&self) -> bool { + pub const fn is_focused(&self) -> bool { self.is_focused } |