From 7f766ff4e56d9cf0721eceec9aca81f53343cb57 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Fri, 14 Jun 2024 00:34:32 +0700 Subject: [PATCH] examples: Use `clamp` (#613) This satisfies a clippy lint that is newly enabled in 1.79. --- examples/scenes/src/pico_svg.rs | 2 +- examples/with_winit/src/stats.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/scenes/src/pico_svg.rs b/examples/scenes/src/pico_svg.rs index cac14f3a6..e3ed24baf 100644 --- a/examples/scenes/src/pico_svg.rs +++ b/examples/scenes/src/pico_svg.rs @@ -272,7 +272,7 @@ fn modify_opacity(mut color: Color, attr_name: &str, node: Node) -> Color { } else { opacity.parse().unwrap_or(1.0) }; - color.a = (alpha.min(1.0).max(0.0) * 255.0).round() as u8; + color.a = (alpha.clamp(0.0, 1.0) * 255.0).round() as u8; color } else { color diff --git a/examples/with_winit/src/stats.rs b/examples/with_winit/src/stats.rs index ae64d1862..3b5339dee 100644 --- a/examples/with_winit/src/stats.rs +++ b/examples/with_winit/src/stats.rs @@ -37,7 +37,7 @@ impl Snapshot { ) where T: Iterator, { - let width = (viewport_width * 0.4).max(200.).min(600.); + let width = (viewport_width * 0.4).clamp(200., 600.); let height = width * 0.7; let x_offset = viewport_width - width; let y_offset = viewport_height - height;