summaryrefslogtreecommitdiffstats
path: root/native/src/layout
diff options
context:
space:
mode:
authorLibravatar Nikolai Vazquez <nikvzqz@gmail.com>2019-11-29 21:24:52 -0500
committerLibravatar Nikolai Vazquez <nikvzqz@gmail.com>2019-11-29 21:24:52 -0500
commit267e242238fab0aba14fb4c2e27269ce3a3e3951 (patch)
tree6957be383f221ecc444ac50cdcbdfd45f6374349 /native/src/layout
parent811d8b90d71c26100f0933217f5474e090fbf17c (diff)
downloadiced-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/layout')
-rw-r--r--native/src/layout/limits.rs6
-rw-r--r--native/src/layout/node.rs8
2 files changed, 7 insertions, 7 deletions
diff --git a/native/src/layout/limits.rs b/native/src/layout/limits.rs
index 2705a47d..5f456871 100644
--- a/native/src/layout/limits.rs
+++ b/native/src/layout/limits.rs
@@ -20,7 +20,7 @@ impl Limits {
///
/// [`Limits`]: struct.Limits.html
/// [`Size`]: ../struct.Size.html
- pub fn new(min: Size, max: Size) -> Limits {
+ pub const fn new(min: Size, max: Size) -> Limits {
Limits {
min,
max,
@@ -32,7 +32,7 @@ impl Limits {
///
/// [`Limits`]: struct.Limits.html
/// [`Size`]: ../struct.Size.html
- pub fn min(&self) -> Size {
+ pub const fn min(&self) -> Size {
self.min
}
@@ -40,7 +40,7 @@ impl Limits {
///
/// [`Limits`]: struct.Limits.html
/// [`Size`]: ../struct.Size.html
- pub fn max(&self) -> Size {
+ pub const fn max(&self) -> Size {
self.max
}
diff --git a/native/src/layout/node.rs b/native/src/layout/node.rs
index ed1cd3da..3b63914e 100644
--- a/native/src/layout/node.rs
+++ b/native/src/layout/node.rs
@@ -12,7 +12,7 @@ impl Node {
///
/// [`Node`]: struct.Node.html
/// [`Size`]: ../struct.Size.html
- pub fn new(size: Size) -> Self {
+ pub const fn new(size: Size) -> Self {
Self::with_children(size, Vec::new())
}
@@ -20,7 +20,7 @@ impl Node {
///
/// [`Node`]: struct.Node.html
/// [`Size`]: ../struct.Size.html
- pub fn with_children(size: Size, children: Vec<Node>) -> Self {
+ pub const fn with_children(size: Size, children: Vec<Node>) -> Self {
Node {
bounds: Rectangle {
x: 0.0,
@@ -36,14 +36,14 @@ impl Node {
///
/// [`Node`]: struct.Node.html
/// [`Size`]: ../struct.Size.html
- pub fn size(&self) -> Size {
+ pub const fn size(&self) -> Size {
Size::new(self.bounds.width, self.bounds.height)
}
/// Returns the bounds of the [`Node`].
///
/// [`Node`]: struct.Node.html
- pub fn bounds(&self) -> Rectangle {
+ pub const fn bounds(&self) -> Rectangle {
self.bounds
}