Ensure Float position is in range 0.0..=1.0

This commit is contained in:
Joscha 2023-02-18 14:07:25 +01:00
parent caca3b6ef1
commit e666d5c092

View file

@ -19,16 +19,19 @@ impl<I> Float<I> {
} }
pub fn horizontal(mut self, position: f32) -> Self { pub fn horizontal(mut self, position: f32) -> Self {
assert!((0.0..=1.0).contains(&position));
self.horizontal = Some(position); self.horizontal = Some(position);
self self
} }
pub fn vertical(mut self, position: f32) -> Self { pub fn vertical(mut self, position: f32) -> Self {
assert!((0.0..=1.0).contains(&position));
self.vertical = Some(position); self.vertical = Some(position);
self self
} }
pub fn all(self, position: f32) -> Self { pub fn all(self, position: f32) -> Self {
assert!((0.0..=1.0).contains(&position));
self.horizontal(position).vertical(position) self.horizontal(position).vertical(position)
} }