Skip to content

Commit efd0ff6

Browse files
committed
Chore: Apply some minor clippy fixes
* Use `.elapsed()` for duration * Use direct iteration without calling `.iter()` and the like * order fields in the `Text` struct creation as declared
1 parent 4613eb2 commit efd0ff6

7 files changed

Lines changed: 13 additions & 19 deletions

File tree

core/src/gradient.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl Linear {
9494
mut self,
9595
stops: impl IntoIterator<Item = ColorStop>,
9696
) -> Self {
97-
for stop in stops.into_iter() {
97+
for stop in stops {
9898
self = self.add_stop(stop.offset, stop.color)
9999
}
100100

core/src/widget/text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ where
220220
size,
221221
line_height,
222222
font,
223-
shaping,
224223
horizontal_alignment,
225224
vertical_alignment,
225+
shaping,
226226
},
227227
);
228228

examples/game_of_life/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ mod grid {
793793
}
794794
}
795795

796-
for (cell, amount) in adjacent_life.iter() {
796+
for (cell, amount) in &adjacent_life {
797797
match amount {
798798
2 => {}
799799
3 => {

examples/tour/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ impl<'a> Step {
482482
column(
483483
Language::all()
484484
.iter()
485-
.cloned()
485+
.copied()
486486
.map(|language| {
487487
radio(
488488
language,

graphics/src/gradient.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl Linear {
8787
mut self,
8888
stops: impl IntoIterator<Item = ColorStop>,
8989
) -> Self {
90-
for stop in stops.into_iter() {
90+
for stop in stops {
9191
self = self.add_stop(stop.offset, stop.color)
9292
}
9393

runtime/src/debug/basic.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,61 +75,55 @@ impl Debug {
7575
}
7676

7777
pub fn startup_finished(&mut self) {
78-
self.startup_duration = time::Instant::now() - self.startup_start;
78+
self.startup_duration = self.startup_start.elapsed();
7979
}
8080

8181
pub fn update_started(&mut self) {
8282
self.update_start = time::Instant::now();
8383
}
8484

8585
pub fn update_finished(&mut self) {
86-
self.update_durations
87-
.push(time::Instant::now() - self.update_start);
86+
self.update_durations.push(self.update_start.elapsed());
8887
}
8988

9089
pub fn view_started(&mut self) {
9190
self.view_start = time::Instant::now();
9291
}
9392

9493
pub fn view_finished(&mut self) {
95-
self.view_durations
96-
.push(time::Instant::now() - self.view_start);
94+
self.view_durations.push(self.view_start.elapsed());
9795
}
9896

9997
pub fn layout_started(&mut self) {
10098
self.layout_start = time::Instant::now();
10199
}
102100

103101
pub fn layout_finished(&mut self) {
104-
self.layout_durations
105-
.push(time::Instant::now() - self.layout_start);
102+
self.layout_durations.push(self.layout_start.elapsed());
106103
}
107104

108105
pub fn event_processing_started(&mut self) {
109106
self.event_start = time::Instant::now();
110107
}
111108

112109
pub fn event_processing_finished(&mut self) {
113-
self.event_durations
114-
.push(time::Instant::now() - self.event_start);
110+
self.event_durations.push(self.event_start.elapsed());
115111
}
116112

117113
pub fn draw_started(&mut self) {
118114
self.draw_start = time::Instant::now();
119115
}
120116

121117
pub fn draw_finished(&mut self) {
122-
self.draw_durations
123-
.push(time::Instant::now() - self.draw_start);
118+
self.draw_durations.push(self.draw_start.elapsed());
124119
}
125120

126121
pub fn render_started(&mut self) {
127122
self.render_start = time::Instant::now();
128123
}
129124

130125
pub fn render_finished(&mut self) {
131-
self.render_durations
132-
.push(time::Instant::now() - self.render_start);
126+
self.render_durations.push(self.render_start.elapsed());
133127
}
134128

135129
pub fn log_message<Message: std::fmt::Debug>(&mut self, message: &Message) {

tiny_skia/src/geometry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn convert_path(path: &Path) -> Option<tiny_skia::Path> {
182182
let mut builder = tiny_skia::PathBuilder::new();
183183
let mut last_point = Default::default();
184184

185-
for event in path.raw().iter() {
185+
for event in path.raw() {
186186
match event {
187187
lyon_path::Event::Begin { at } => {
188188
builder.move_to(at.x, at.y);

0 commit comments

Comments
 (0)