use 'clamp' function (clippy::manual_clamp)

This commit is contained in:
Daniel Eades 2024-04-14 21:08:03 +01:00 committed by Jeremy Soller
parent 4b7c0ca15a
commit d3eb8d5ad0
2 changed files with 3 additions and 3 deletions

View file

@ -364,7 +364,7 @@ where
if !metadata.flags.is_empty() {
let style_line_height =
(self.glyph_font_size / 10.0).max(2.0).min(16.0);
(self.glyph_font_size / 10.0).clamp(2.0, 16.0);
let line_color = cosmic_text_to_iced_color(metadata.underline_color);

View file

@ -55,8 +55,8 @@ impl ColorDerive {
fn color_adj(rgb: Rgb, saturation_adj: f32, lightness_adj: f32) -> Rgb {
let mut okhsl = Self::rgb_to_okhsl(rgb);
okhsl.saturation = (okhsl.saturation + saturation_adj).max(0.0).min(1.0);
okhsl.lightness = (okhsl.lightness + lightness_adj).max(0.0).min(1.0);
okhsl.saturation = (okhsl.saturation + saturation_adj).clamp(0.0, 1.0);
okhsl.lightness = (okhsl.lightness + lightness_adj).clamp(0.0, 1.0);
Self::okhsl_to_rgb(okhsl)
}