Skip to content

Commit ce0e2b6

Browse files
committed
fix clippy
1 parent 92670c9 commit ce0e2b6

2 files changed

Lines changed: 6 additions & 18 deletions

File tree

shared/src/lib.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct ShaderConstants {
3131
}
3232

3333
pub fn saturate(x: f32) -> f32 {
34-
x.max(0.0).min(1.0)
34+
x.clamp(0.0, 1.0)
3535
}
3636

3737
/// Based on: https://seblagarde.wordpress.com/2014/12/01/inverse-trigonometric-functions-gpu-optimization-for-amd-gcn-architecture/
@@ -62,16 +62,6 @@ pub fn mix<X: Copy + Mul<A, Output = X> + Add<Output = X> + Sub<Output = X>, A:
6262
x - x * a + y * a
6363
}
6464

65-
pub trait Clamp {
66-
fn clamp(self, min: Self, max: Self) -> Self;
67-
}
68-
69-
impl Clamp for f32 {
70-
fn clamp(self, min: Self, max: Self) -> Self {
71-
self.max(min).min(max)
72-
}
73-
}
74-
7565
pub trait FloatExt {
7666
fn fract_gl(self) -> Self;
7767
fn rem_euclid(self, rhs: Self) -> Self;
@@ -232,5 +222,5 @@ impl VecExt for Vec4 {
232222
}
233223

234224
pub fn discard() {
235-
unsafe { spirv_std::arch::demote_to_helper_invocation() }
225+
spirv_std::arch::demote_to_helper_invocation()
236226
}

src/main.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl ShaderToyApp {
199199
let frame = match surface.get_current_texture() {
200200
Ok(frame) => frame,
201201
Err(e) => {
202-
eprintln!("Failed to acquire texture: {:?}", e);
202+
eprintln!("Failed to acquire texture: {e:?}");
203203
return;
204204
}
205205
};
@@ -306,11 +306,9 @@ impl ApplicationHandler for ShaderToyApp {
306306
}
307307
}
308308
}
309-
WindowEvent::MouseWheel { delta, .. } => {
310-
if let winit::event::MouseScrollDelta::LineDelta(x, y) = delta {
311-
self.drag_end_x = x * 0.1;
312-
self.drag_end_y = y * 0.1;
313-
}
309+
WindowEvent::MouseWheel { delta: winit::event::MouseScrollDelta::LineDelta(x, y), .. } => {
310+
self.drag_end_x = x * 0.1;
311+
self.drag_end_y = y * 0.1;
314312
}
315313
WindowEvent::KeyboardInput { event, .. } => {
316314
if event.logical_key == NamedKey::Escape && event.state == ElementState::Pressed {

0 commit comments

Comments
 (0)