From e666d5c092b3c62e15891961db17056f8175a807 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sat, 18 Feb 2023 14:07:25 +0100 Subject: [PATCH] Ensure Float position is in range 0.0..=1.0 --- src/widgets/float.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/widgets/float.rs b/src/widgets/float.rs index e9c7ed8..d3eff4b 100644 --- a/src/widgets/float.rs +++ b/src/widgets/float.rs @@ -19,16 +19,19 @@ impl Float { } pub fn horizontal(mut self, position: f32) -> Self { + assert!((0.0..=1.0).contains(&position)); self.horizontal = Some(position); self } pub fn vertical(mut self, position: f32) -> Self { + assert!((0.0..=1.0).contains(&position)); self.vertical = Some(position); self } pub fn all(self, position: f32) -> Self { + assert!((0.0..=1.0).contains(&position)); self.horizontal(position).vertical(position) }