From 25a7dc7e182d6502f48d55790412f9bbcd133fd3 Mon Sep 17 00:00:00 2001 From: Victoria Fischer Date: Fri, 17 Oct 2025 20:28:17 +0200 Subject: [PATCH] animation: write a const Animation::new() --- src/animation.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/animation.rs b/src/animation.rs index d5704bf..e3e13af 100644 --- a/src/animation.rs +++ b/src/animation.rs @@ -53,7 +53,14 @@ impl AnimationActor for AnimatedSurface { } impl Animation { - pub fn from(self, from: u8) -> Self { + pub const fn new() -> Self { + Self { + from: None, + to: None, + duration: Duration::from_ticks(0) + } + } + pub const fn from(self, from: u8) -> Self { Self { from: Some(from), to: self.to, @@ -61,7 +68,7 @@ impl Animation { } } - pub fn to(self, to: u8) -> Self { + pub const fn to(self, to: u8) -> Self { Self { from: self.from, to: Some(to), @@ -69,7 +76,7 @@ impl Animation { } } - pub fn duration(self, duration: Duration) -> Self { + pub const fn duration(self, duration: Duration) -> Self { Self { from: self.from, to: self.to,