Skip to content

Commit 03b60d5

Browse files
andrew-r-thomasprokopyl
authored andcommitted
fixing clippy errors
1 parent 29e9aec commit 03b60d5

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

examples/render_wgpu/src/main.rs

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ impl<'a> WgpuExample {
4444
.formats
4545
.iter()
4646
.copied()
47-
.filter(|f| f.is_srgb())
48-
.next()
47+
.find(|f| f.is_srgb())
4948
.unwrap_or(surface_caps.formats[0]);
5049
let config = wgpu::SurfaceConfiguration {
5150
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
@@ -144,31 +143,27 @@ impl WindowHandler for WgpuExample {
144143
fn on_event(
145144
&mut self, _window: &mut baseview::Window, event: baseview::Event,
146145
) -> baseview::EventStatus {
147-
match event {
148-
baseview::Event::Mouse(MouseEvent::CursorMoved { position, modifiers: _ }) => {
149-
let center_x: f32 = (position.x as f32 - 256.0) / 256.0;
150-
let center_y: f32 = (256.0 - position.y as f32) / 256.0;
151-
let vertices = &[
152-
Vertex { position: [center_x, center_y + 0.25, 0.0], color: [1.0, 0.0, 0.0] },
153-
Vertex {
154-
position: [center_x - 0.25, center_y - 0.25, 0.0],
155-
color: [0.0, 1.0, 0.0],
156-
},
157-
Vertex {
158-
position: [center_x + 0.25, center_y - 0.25, 0.0],
159-
color: [0.0, 0.0, 1.0],
160-
},
161-
];
162-
let vertex_buffer =
163-
self.device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
164-
label: Some("Vertex Buffer"),
165-
contents: bytemuck::cast_slice(vertices),
166-
usage: wgpu::BufferUsages::VERTEX,
167-
});
168-
169-
self.vertex_buffer = vertex_buffer;
170-
}
171-
_ => {}
146+
if let baseview::Event::Mouse(MouseEvent::CursorMoved { position, modifiers: _ }) = event {
147+
let center_x: f32 = (position.x as f32 - 256.0) / 256.0;
148+
let center_y: f32 = (256.0 - position.y as f32) / 256.0;
149+
let vertices = &[
150+
Vertex { position: [center_x, center_y + 0.25, 0.0], color: [1.0, 0.0, 0.0] },
151+
Vertex {
152+
position: [center_x - 0.25, center_y - 0.25, 0.0],
153+
color: [0.0, 1.0, 0.0],
154+
},
155+
Vertex {
156+
position: [center_x + 0.25, center_y - 0.25, 0.0],
157+
color: [0.0, 0.0, 1.0],
158+
},
159+
];
160+
let vertex_buffer = self.device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
161+
label: Some("Vertex Buffer"),
162+
contents: bytemuck::cast_slice(vertices),
163+
usage: wgpu::BufferUsages::VERTEX,
164+
});
165+
166+
self.vertex_buffer = vertex_buffer;
172167
}
173168
baseview::EventStatus::Captured
174169
}

0 commit comments

Comments
 (0)