Skip to content

Commit

Permalink
Some clippy fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaj committed Oct 7, 2024
1 parent 5a1ab7c commit 0a625cb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
4 changes: 3 additions & 1 deletion rsass/src/sass/functions/color/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ pub fn register(f: &mut Scope) {
sat,
lum,
opt_add(hsla.alpha(), a_adj),
hsla.hsla_format || sat > 1. || lum > 1. || lum < 0.,
hsla.hsla_format
|| sat > 1.
|| !(0. ..=1.).contains(&lum),
)
.into())
} else {
Expand Down
1 change: 1 addition & 0 deletions rsass/src/value/colors/hsla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ impl Hsla {
hue: deg_mod(hue),
sat: sat.clamp(0., f64::INFINITY),
lum,
#[allow(clippy::manual_clamp)] // to get correct NaN handling
alpha: alpha.max(0.).min(1.),
hsla_format,
}
Expand Down
19 changes: 7 additions & 12 deletions rsass/src/value/colors/hwba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@ impl Hwba {
/// Hue is modulo 360 degrees. Other inputs will be clamped to
/// their ranges.
pub fn new(hue: f64, w: f64, b: f64, alpha: f64) -> Self {
let mut w = w;
let mut b = b;
let wbsum = w + b;
if !(wbsum < 1.) {
w /= wbsum;
b /= wbsum;
}
Self {
hue,
w,
b,
alpha: alpha.clamp(0., 1.),
}
let (w, b) = if wbsum > 1. {
(w / wbsum, b / wbsum)
} else {
(w, b)
};
let alpha = alpha.clamp(0., 1.);
Self { hue, w, b, alpha }
}

/// Get the hue of this color.
Expand Down
5 changes: 2 additions & 3 deletions rsass/src/variablescope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,8 @@ impl Scope {
let module = module.with_forwarded();
match as_n {
UseAs::KeepName => {
let name = name
.rfind(|c| c == ':' || c == '/')
.map_or(name, |i| &name[i + 1..]);
let name =
name.rfind([':', '/']).map_or(name, |i| &name[i + 1..]);
self.define_module(name.into(), module.expose(expose));
}
UseAs::Star => {
Expand Down

0 comments on commit 0a625cb

Please sign in to comment.