diff options
author | 2019-11-29 21:24:52 -0500 | |
---|---|---|
committer | 2019-11-29 21:24:52 -0500 | |
commit | 267e242238fab0aba14fb4c2e27269ce3a3e3951 (patch) | |
tree | 6957be383f221ecc444ac50cdcbdfd45f6374349 /core | |
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 'core')
-rw-r--r-- | core/src/point.rs | 2 | ||||
-rw-r--r-- | core/src/vector.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/core/src/point.rs b/core/src/point.rs index 183998dd..52307bba 100644 --- a/core/src/point.rs +++ b/core/src/point.rs @@ -14,7 +14,7 @@ impl Point { /// Creates a new [`Point`] with the given coordinates. /// /// [`Point`]: struct.Point.html - pub fn new(x: f32, y: f32) -> Self { + pub const fn new(x: f32, y: f32) -> Self { Self { x, y } } } diff --git a/core/src/vector.rs b/core/src/vector.rs index 7d87343a..e0c5f073 100644 --- a/core/src/vector.rs +++ b/core/src/vector.rs @@ -16,7 +16,7 @@ impl<T> Vector<T> { /// Creates a new [`Vector`] with the given components. /// /// [`Vector`]: struct.Vector.html - pub fn new(x: T, y: T) -> Self { + pub const fn new(x: T, y: T) -> Self { Self { x, y } } } |