From 267e242238fab0aba14fb4c2e27269ce3a3e3951 Mon Sep 17 00:00:00 2001 From: Nikolai Vazquez Date: Fri, 29 Nov 2019 21:24:52 -0500 Subject: 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`. --- native/src/layout/node.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'native/src/layout/node.rs') 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) -> Self { + pub const fn with_children(size: Size, children: Vec) -> 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 } -- cgit