Skip to content

Commit 0db4820

Browse files
committed
[fix] warnings with all examples.
1 parent 6d39a50 commit 0db4820

File tree

12 files changed

+97
-119
lines changed

12 files changed

+97
-119
lines changed

crates/lambda-rs/examples/immediates.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ use lambda::{
77
WindowEvent,
88
},
99
logging,
10-
math::{
11-
matrix,
12-
matrix::Matrix,
13-
vector::Vector,
14-
},
10+
math::matrix::Matrix,
1511
render::{
1612
buffer::BufferBuilder,
1713
command::RenderCommand,
@@ -43,7 +39,6 @@ use lambda::{
4339
runtime::start_runtime,
4440
runtimes::{
4541
application::ComponentResult,
46-
ApplicationRuntime,
4742
ApplicationRuntimeBuilder,
4843
},
4944
};
@@ -156,7 +151,7 @@ impl Component<ComponentResult, String> for ImmediatesExample {
156151

157152
let mut mesh_builder = MeshBuilder::new();
158153
vertices.iter().for_each(|vertex| {
159-
mesh_builder.with_vertex(vertex.clone());
154+
mesh_builder.with_vertex(*vertex);
160155
});
161156

162157
let mesh = mesh_builder
@@ -216,7 +211,7 @@ impl Component<ComponentResult, String> for ImmediatesExample {
216211

217212
fn on_detach(
218213
&mut self,
219-
render_context: &mut lambda::render::RenderContext,
214+
_render_context: &mut lambda::render::RenderContext,
220215
) -> Result<ComponentResult, String> {
221216
logging::info!("Detaching component");
222217
return Ok(ComponentResult::Success);
@@ -227,13 +222,10 @@ impl Component<ComponentResult, String> for ImmediatesExample {
227222
}
228223

229224
fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> {
230-
match event {
231-
WindowEvent::Resize { width, height } => {
232-
self.width = *width;
233-
self.height = *height;
234-
logging::info!("Window resized to {}x{}", width, height);
235-
}
236-
_ => {}
225+
if let WindowEvent::Resize { width, height } = event {
226+
self.width = *width;
227+
self.height = *height;
228+
logging::info!("Window resized to {}x{}", width, height);
237229
}
238230
return Ok(());
239231
}
@@ -249,7 +241,7 @@ impl Component<ComponentResult, String> for ImmediatesExample {
249241

250242
fn on_render(
251243
&mut self,
252-
render_context: &mut lambda::render::RenderContext,
244+
_render_context: &mut lambda::render::RenderContext,
253245
) -> Vec<lambda::render::command::RenderCommand> {
254246
let camera = SimpleCamera {
255247
position: [0.0, 0.0, 3.0],
@@ -281,12 +273,11 @@ impl Component<ComponentResult, String> for ImmediatesExample {
281273
RenderCommand::BeginRenderPass {
282274
render_pass: self
283275
.render_pass
284-
.expect("Cannot begin the render pass when it doesn't exist.")
285-
.clone(),
276+
.expect("Cannot begin the render pass when it doesn't exist."),
286277
viewport: viewport.clone(),
287278
},
288279
RenderCommand::SetPipeline {
289-
pipeline: render_pipeline.clone(),
280+
pipeline: render_pipeline,
290281
},
291282
RenderCommand::SetViewports {
292283
start_at: 0,
@@ -297,11 +288,11 @@ impl Component<ComponentResult, String> for ImmediatesExample {
297288
viewports: vec![viewport.clone()],
298289
},
299290
RenderCommand::BindVertexBuffer {
300-
pipeline: render_pipeline.clone(),
291+
pipeline: render_pipeline,
301292
buffer: 0,
302293
},
303294
RenderCommand::Immediates {
304-
pipeline: render_pipeline.clone(),
295+
pipeline: render_pipeline,
305296
offset: 0,
306297
bytes: Vec::from(immediate_data_to_bytes(&ImmediateData {
307298
data: [0.0, 0.0, 0.0, 0.0],

crates/lambda-rs/examples/indexed_multi_vertex_buffers.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ use lambda::{
4848
runtime::start_runtime,
4949
runtimes::{
5050
application::ComponentResult,
51-
ApplicationRuntime,
5251
ApplicationRuntimeBuilder,
5352
},
5453
};
@@ -235,13 +234,10 @@ impl Component<ComponentResult, String> for IndexedMultiBufferExample {
235234
}
236235

237236
fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> {
238-
match event {
239-
WindowEvent::Resize { width, height } => {
240-
self.width = *width;
241-
self.height = *height;
242-
logging::info!("Window resized to {}x{}", width, height);
243-
}
244-
_ => {}
237+
if let WindowEvent::Resize { width, height } = event {
238+
self.width = *width;
239+
self.height = *height;
240+
logging::info!("Window resized to {}x{}", width, height);
245241
}
246242
return Ok(());
247243
}

crates/lambda-rs/examples/instanced_quads.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,10 @@ impl Component<ComponentResult, String> for InstancedQuadsExample {
263263
}
264264

265265
fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> {
266-
match event {
267-
WindowEvent::Resize { width, height } => {
268-
self.width = *width;
269-
self.height = *height;
270-
logging::info!("Window resized to {}x{}", width, height);
271-
}
272-
_ => {}
266+
if let WindowEvent::Resize { width, height } = event {
267+
self.width = *width;
268+
self.height = *height;
269+
logging::info!("Window resized to {}x{}", width, height);
273270
}
274271
return Ok(());
275272
}

crates/lambda-rs/examples/minimal.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
//! applications or to verify that your system is configured to run lambda
55
//! applications correctly.
66
7-
#[macro_use]
87
use lambda::{
98
runtime::start_runtime,
109
runtimes::ApplicationRuntimeBuilder,

crates/lambda-rs/examples/offscreen_post.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,9 @@ impl Component<ComponentResult, String> for OffscreenPostExample {
221221
}
222222

223223
fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> {
224-
match event {
225-
WindowEvent::Resize { width, height } => {
226-
self.width = *width;
227-
self.height = *height;
228-
}
229-
_ => {}
224+
if let WindowEvent::Resize { width, height } = event {
225+
self.width = *width;
226+
self.height = *height;
230227
}
231228
return Ok(());
232229
}

crates/lambda-rs/examples/reflective_room.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ impl ReflectiveRoomExample {
664664

665665
// Reflected cube pipeline
666666
self.pipe_reflected = if self.stencil_enabled {
667-
let mut builder = RenderPipelineBuilder::new()
667+
let builder = RenderPipelineBuilder::new()
668668
.with_label("reflected-cube")
669669
// Mirrored transform reverses winding; cull front to keep visible faces.
670670
.with_culling(CullingMode::Front)

crates/lambda-rs/examples/textured_cube.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl Component<ComponentResult, String> for TexturedCubeExample {
304304
let i = ((y * tex_w + x) * 4) as usize;
305305
let checker = ((x / 8) % 2) ^ ((y / 8) % 2);
306306
let c: u8 = if checker == 0 { 40 } else { 220 };
307-
pixels[i + 0] = c;
307+
pixels[i] = c;
308308
pixels[i + 1] = c;
309309
pixels[i + 2] = c;
310310
pixels[i + 3] = 255;
@@ -373,12 +373,9 @@ impl Component<ComponentResult, String> for TexturedCubeExample {
373373
}
374374

375375
fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> {
376-
match event {
377-
WindowEvent::Resize { width, height } => {
378-
self.width = *width;
379-
self.height = *height;
380-
}
381-
_ => {}
376+
if let WindowEvent::Resize { width, height } = event {
377+
self.width = *width;
378+
self.height = *height;
382379
}
383380
return Ok(());
384381
}

crates/lambda-rs/examples/textured_quad.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl Component<ComponentResult, String> for TexturedQuadExample {
205205
let i = ((y * tex_w + x) * 4) as usize;
206206
let checker = ((x / 8) % 2) ^ ((y / 8) % 2);
207207
let c = if checker == 0 { 40 } else { 220 };
208-
pixels[i + 0] = c; // R
208+
pixels[i] = c; // R
209209
pixels[i + 1] = c; // G
210210
pixels[i + 2] = c; // B
211211
pixels[i + 3] = 255; // A
@@ -275,12 +275,9 @@ impl Component<ComponentResult, String> for TexturedQuadExample {
275275
}
276276

277277
fn on_window_event(&mut self, event: &WindowEvent) -> Result<(), String> {
278-
match event {
279-
WindowEvent::Resize { width, height } => {
280-
self.width = *width;
281-
self.height = *height;
282-
}
283-
_ => {}
278+
if let WindowEvent::Resize { width, height } = event {
279+
self.width = *width;
280+
self.height = *height;
284281
}
285282
return Ok(());
286283
}

crates/lambda-rs/examples/triangle.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl Component<ComponentResult, String> for DemoComponent {
6868

6969
fn on_detach(
7070
self: &mut DemoComponent,
71-
render_context: &mut RenderContext,
71+
_render_context: &mut RenderContext,
7272
) -> Result<ComponentResult, String> {
7373
return Ok(ComponentResult::Success);
7474
}
@@ -119,12 +119,9 @@ impl Component<ComponentResult, String> for DemoComponent {
119119
self: &mut DemoComponent,
120120
last_frame: &std::time::Duration,
121121
) -> Result<ComponentResult, String> {
122-
match last_frame.as_millis() > 20 {
123-
true => {
124-
logging::warn!("Last frame took {}ms", last_frame.as_millis());
125-
}
126-
false => {}
127-
};
122+
if last_frame.as_millis() > 20 {
123+
logging::warn!("Last frame took {}ms", last_frame.as_millis());
124+
}
128125
return Ok(ComponentResult::Success);
129126
}
130127
fn on_render(
@@ -168,7 +165,6 @@ impl DemoComponent {}
168165

169166
impl Default for DemoComponent {
170167
/// Load in shaders upon creation.
171-
172168
fn default() -> Self {
173169
// Specify virtual shaders to use for rendering
174170
let triangle_vertex = VirtualShader::Source {

crates/lambda-rs/examples/triangles.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,12 @@ impl Component<ComponentResult, String> for TrianglesComponent {
123123
let mut commands = vec![RenderCommand::BeginRenderPass {
124124
render_pass: self
125125
.render_pass
126-
.expect("Cannot begin the render pass when it doesn't exist.")
127-
.clone(),
126+
.expect("Cannot begin the render pass when it doesn't exist."),
128127
viewport: viewport.clone(),
129128
}];
130129

131130
commands.push(RenderCommand::SetPipeline {
132-
pipeline: render_pipeline.clone(),
131+
pipeline: render_pipeline,
133132
});
134133
commands.push(RenderCommand::SetViewports {
135134
start_at: 0,
@@ -144,7 +143,7 @@ impl Component<ComponentResult, String> for TrianglesComponent {
144143
// before requesting to draw each triangle.
145144
for triangle in triangle_data {
146145
commands.push(RenderCommand::Immediates {
147-
pipeline: render_pipeline.clone(),
146+
pipeline: render_pipeline,
148147
offset: 0,
149148
bytes: Vec::from(immediate_data_to_bytes(triangle)),
150149
});
@@ -178,11 +177,12 @@ impl Component<ComponentResult, String> for TrianglesComponent {
178177
}
179178

180179
fn on_keyboard_event(&mut self, event: &Key) -> Result<(), String> {
181-
match event {
182-
Key::Pressed {
183-
scan_code: _,
184-
virtual_key,
185-
} => match virtual_key {
180+
if let Key::Pressed {
181+
scan_code: _,
182+
virtual_key,
183+
} = event
184+
{
185+
match virtual_key {
186186
Some(VirtualKey::KeyW) => {
187187
self.position.1 -= 0.01;
188188
}
@@ -196,8 +196,7 @@ impl Component<ComponentResult, String> for TrianglesComponent {
196196
self.position.0 += 0.01;
197197
}
198198
_ => {}
199-
},
200-
_ => {}
199+
}
201200
}
202201
return Ok(());
203202
}
@@ -206,12 +205,9 @@ impl Component<ComponentResult, String> for TrianglesComponent {
206205
&mut self,
207206
last_frame: &std::time::Duration,
208207
) -> Result<ComponentResult, String> {
209-
match last_frame.as_millis() > 20 {
210-
true => {
211-
logging::warn!("Last frame took {}ms", last_frame.as_millis());
212-
}
213-
false => {}
214-
};
208+
if last_frame.as_millis() > 20 {
209+
logging::warn!("Last frame took {}ms", last_frame.as_millis());
210+
}
215211
return Ok(ComponentResult::Success);
216212
}
217213
}
@@ -237,7 +233,6 @@ pub fn immediate_data_to_bytes(immediate_data: &ImmediateData) -> &[u32] {
237233

238234
impl Default for TrianglesComponent {
239235
/// Load in shaders upon creation.
240-
241236
fn default() -> Self {
242237
// Specify virtual shaders to use for rendering
243238
let triangle_vertex = VirtualShader::Source {

0 commit comments

Comments
 (0)