animation: write a const Animation::new()

This commit is contained in:
2025-10-17 20:28:17 +02:00
parent 36826fbedc
commit 25a7dc7e18

View File

@@ -53,7 +53,14 @@ impl<S: Surface> AnimationActor for AnimatedSurface<S> {
} }
impl Animation { 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 { Self {
from: Some(from), from: Some(from),
to: self.to, 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 { Self {
from: self.from, from: self.from,
to: Some(to), 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 { Self {
from: self.from, from: self.from,
to: self.to, to: self.to,