Skip to content

Commit

Permalink
Note and cleanup in clamp.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaj committed Jul 3, 2021
1 parent f9678c7 commit de26773
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/value/colors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ impl From<Hwba> for Color {
}

fn clamp(v: Rational, min: Rational, max: Rational) -> Rational {
let v = if v < min { min } else { v };
if v > max {
// Note: Ord.clamp is in std from 1.50.0.
if v >= max {
max
} else if v <= min {
min
} else {
v
}
Expand Down

0 comments on commit de26773

Please sign in to comment.