Skip to content

Commit a4496ac

Browse files
committed
Fix some clippy lints
1 parent 740cdf0 commit a4496ac

File tree

8 files changed

+24
-26
lines changed

8 files changed

+24
-26
lines changed

examples/scenes/src/pico_svg.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ impl Parser {
172172
path: path.clone(),
173173
}));
174174
}
175-
if let Some(stroke_color) = node.attribute("stroke") {
176-
if stroke_color != "none" {
175+
if let Some(stroke_color) = node.attribute("stroke")
176+
&& stroke_color != "none" {
177177
let width = node
178178
.attribute("stroke-width")
179179
.map(|a| f64::from_str(a).unwrap_or(1.0))
@@ -185,7 +185,6 @@ impl Parser {
185185
let color = modify_opacity(color, "opacity", node);
186186
items.push(Item::Stroke(StrokeItem { width, color, path }));
187187
}
188-
}
189188
}
190189
other => eprintln!("Unhandled node type {other}"),
191190
}

examples/scenes/src/svg.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ fn scene_from_files_inner(files: &[PathBuf]) -> std::result::Result<SceneSet, an
3939
let start_index = scenes.len();
4040
for file in read_dir(path)? {
4141
let entry = file?;
42-
if let Some(extension) = Path::new(&entry.file_name()).extension() {
43-
if extension == "svg" {
42+
if let Some(extension) = Path::new(&entry.file_name()).extension()
43+
&& extension == "svg" {
4444
scenes.push(example_scene_of(entry.path()));
4545
}
46-
}
4746
}
4847
// Ensure a consistent order within directories
4948
scenes[start_index..].sort_by_key(|scene| scene.config.name.to_lowercase());

examples/with_winit/src/lib.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,7 @@ impl ApplicationHandler<UserEvent> for VelloApp {
411411
valid_surface,
412412
..
413413
}) = &self.state
414-
{
415-
if *valid_surface
414+
&& *valid_surface
416415
&& touch.location.y > surface.config.height as f64 * 2. / 3.
417416
{
418417
self.navigation_fingers.insert(touch.id);
@@ -423,7 +422,6 @@ impl ApplicationHandler<UserEvent> for VelloApp {
423422
self.scene_ix = self.scene_ix.saturating_add(1);
424423
}
425424
}
426-
}
427425
}
428426
TouchPhase::Ended | TouchPhase::Cancelled => {
429427
// We intentionally ignore the result here
@@ -485,11 +483,10 @@ impl ApplicationHandler<UserEvent> for VelloApp {
485483
x: position.x,
486484
y: position.y,
487485
};
488-
if self.mouse_down {
489-
if let Some(prior) = self.prior_position {
486+
if self.mouse_down
487+
&& let Some(prior) = self.prior_position {
490488
self.transform = self.transform.then_translate(position - prior);
491489
}
492-
}
493490
self.prior_position = Some(position);
494491
}
495492
WindowEvent::RedrawRequested => {
@@ -578,14 +575,12 @@ impl ApplicationHandler<UserEvent> for VelloApp {
578575
if let Some(profiling_result) = self.renderers[surface.dev_id]
579576
.as_mut()
580577
.and_then(|renderer| renderer.profile_result.take())
581-
{
582-
if self.profile_stored.is_none()
583-
|| self.profile_taken.elapsed() > Duration::from_secs(1)
578+
&& (self.profile_stored.is_none()
579+
|| self.profile_taken.elapsed() > Duration::from_secs(1))
584580
{
585581
self.profile_stored = Some(profiling_result);
586582
self.profile_taken = Instant::now();
587583
}
588-
}
589584
#[cfg(feature = "wgpu-profiler")]
590585
if let Some(profiling_result) = self.profile_stored.as_ref() {
591586
stats::draw_gpu_profiling(

sparse_strips/vello_common/src/clip.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ struct ClipData {
1919
impl ClipData {
2020
fn to_path_data_ref<'a>(&self, storage: &'a StripStorage) -> PathDataRef<'a> {
2121
PathDataRef {
22-
strips: &storage
22+
strips: storage
2323
.strips
2424
.get(self.strip_start as usize..)
2525
.unwrap_or(&[]),
26-
alphas: &storage
26+
alphas: storage
2727
.alphas
2828
.get(self.alpha_start as usize..)
2929
.unwrap_or(&[]),
@@ -39,6 +39,12 @@ pub struct ClipContext {
3939
clip_stack: Vec<ClipData>,
4040
}
4141

42+
impl Default for ClipContext {
43+
fn default() -> Self {
44+
Self::new()
45+
}
46+
}
47+
4248
impl ClipContext {
4349
/// Create a new clip context.
4450
#[inline]

sparse_strips/vello_common/src/strip_generator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl StripStorage {
5151
}
5252

5353
/// Extend the current strip storage with the data from another storage.
54-
pub fn extend(&mut self, other: &StripStorage) {
54+
pub fn extend(&mut self, other: &Self) {
5555
self.strips.extend(&other.strips);
5656
self.alphas.extend(&other.alphas);
5757
}
@@ -101,7 +101,7 @@ impl StripGenerator {
101101
&mut self.flatten_ctx,
102102
);
103103

104-
self.generate_with_clip(aliasing_threshold, strip_storage, fill_rule, clip_path)
104+
self.generate_with_clip(aliasing_threshold, strip_storage, fill_rule, clip_path);
105105
}
106106

107107
/// Generate the strips for a stroked path.
@@ -122,7 +122,7 @@ impl StripGenerator {
122122
&mut self.line_buf,
123123
&mut self.flatten_ctx,
124124
);
125-
self.generate_with_clip(aliasing_threshold, strip_storage, Fill::NonZero, clip_path)
125+
self.generate_with_clip(aliasing_threshold, strip_storage, Fill::NonZero, clip_path);
126126
}
127127

128128
fn generate_with_clip(

sparse_strips/vello_cpu/src/dispatch/single_threaded.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl Dispatcher for SingleThreadedDispatcher {
215215
fill_rule,
216216
transform,
217217
aliasing_threshold,
218-
)
218+
);
219219
}
220220

221221
fn pop_clip_path(&mut self) {

sparse_strips/vello_cpu/src/render.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl RenderContext {
428428
self.fill_rule,
429429
self.transform,
430430
self.aliasing_threshold,
431-
)
431+
);
432432
}
433433

434434
/// Pop a clip path from the clip stack.

sparse_strips/vello_hybrid/examples/winit/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,10 @@ impl ApplicationHandler for App<'_> {
203203
event_loop.exit();
204204
}
205205
Key::Character(ch) => {
206-
if let Some(scene) = self.scenes.get_mut(self.current_scene) {
207-
if scene.handle_key(ch.as_str()) {
206+
if let Some(scene) = self.scenes.get_mut(self.current_scene)
207+
&& scene.handle_key(ch.as_str()) {
208208
window.request_redraw();
209209
}
210-
}
211210
}
212211
_ => {}
213212
},

0 commit comments

Comments
 (0)