Skip to content

Commit

Permalink
Fix overflow issues when bounds min or max is set to T min or max
Browse files Browse the repository at this point in the history
  • Loading branch information
genusistimelord committed May 7, 2024
1 parent 477dbf8 commit b45d2b3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/widgets/number_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,18 @@ where

/// Decrease current value by step of the [`NumberInput`].
fn decrease_val(&mut self, shell: &mut Shell<Message>) {
if self.bounds.1 - self.bounds.0 < self.step || self.value < self.bounds.0 + self.step {
if self.value < self.bounds.0 + self.step {
self.value = self.bounds.0;
} else {
self.value -= self.step;
}

shell.publish((self.on_change)(self.value));
}

/// Increase current value by step of the [`NumberInput`].
fn increase_val(&mut self, shell: &mut Shell<Message>) {
if self.bounds.1 - self.bounds.0 < self.step || self.value > self.bounds.1 - self.step {
if self.value > self.bounds.1 - self.step {
self.value = self.bounds.1;
} else {
self.value += self.step;
Expand Down

0 comments on commit b45d2b3

Please sign in to comment.