Skip to content

Commit

Permalink
Fix stack overflow
Browse files Browse the repository at this point in the history
Fixes #242
  • Loading branch information
devongovett committed Jul 31, 2022
1 parent 477ce00 commit c1c67e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ pub trait Sign {

/// Returns whether the value is positive.
fn is_sign_positive(&self) -> bool {
self.sign().is_sign_positive()
f32::is_sign_positive(self.sign())
}

/// Returns whether the value is negative.
fn is_sign_negative(&self) -> bool {
self.sign().is_sign_negative()
f32::is_sign_negative(self.sign())
}
}

Expand All @@ -199,12 +199,12 @@ pub trait TrySign {

/// Returns whether the value is positive. If not possible, returns false.
fn is_sign_positive(&self) -> bool {
self.try_sign().map_or(false, |s| s.is_sign_positive())
self.try_sign().map_or(false, |s| f32::is_sign_positive(s))
}

/// Returns whether the value is negative. If not possible, returns false.
fn is_sign_negative(&self) -> bool {
self.try_sign().map_or(false, |s| s.is_sign_negative())
self.try_sign().map_or(false, |s| f32::is_sign_negative(s))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/values/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Map for CSSNumber {
impl Sign for CSSNumber {
fn sign(&self) -> f32 {
if *self == 0.0 {
return if self.is_sign_positive() { 0.0 } else { -0.0 };
return if f32::is_sign_positive(*self) { 0.0 } else { -0.0 };
}
self.signum()
}
Expand Down

0 comments on commit c1c67e0

Please sign in to comment.