Skip to content

Commit 6d69d49

Browse files
authored
Merge pull request #861 from Sharktheone/clippy/happy-again
2 parents f5764b7 + f36bb9a commit 6d69d49

File tree

136 files changed

+1271
-985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+1271
-985
lines changed

benches/bytestream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn utf8_testfile(c: &mut Criterion) {
1717
while !stream.eof() {
1818
stream.read_and_next();
1919
}
20-
})
20+
});
2121
});
2222

2323
group.finish();

benches/tree_iterator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn wikipedia_main_page(c: &mut Criterion) {
4545
b.iter(|| {
4646
let tree_iterator = TreeIterator::<Config>::new(&doc);
4747
let _ = tree_iterator.collect::<Vec<NodeId>>();
48-
})
48+
});
4949
});
5050

5151
group.finish();
@@ -70,7 +70,7 @@ fn stackoverflow_home(c: &mut Criterion) {
7070
b.iter(|| {
7171
let tree_iterator = TreeIterator::<Config>::new(&doc);
7272
let _ = tree_iterator.collect::<Vec<NodeId>>();
73-
})
73+
});
7474
});
7575

7676
group.finish();

crates/gosub_cairo/src/elements/border.rs

Lines changed: 96 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct GsBorderRenderSideOptions<'a> {
4242
}
4343

4444
impl<'a> GsBorderRenderOptions<'a> {
45-
fn left(&self, transform: Option<&'a GsTransform>) -> Option<GsBorderRenderSideOptions> {
45+
fn left(&self, transform: Option<&'a GsTransform>) -> Option<GsBorderRenderSideOptions<'_>> {
4646
let segment = self.border.border.left.as_ref()?;
4747

4848
Some(GsBorderRenderSideOptions {
@@ -54,7 +54,7 @@ impl<'a> GsBorderRenderOptions<'a> {
5454
})
5555
}
5656

57-
fn right(&self, transform: Option<&'a GsTransform>) -> Option<GsBorderRenderSideOptions> {
57+
fn right(&self, transform: Option<&'a GsTransform>) -> Option<GsBorderRenderSideOptions<'_>> {
5858
let segment = self.border.border.right.as_ref()?;
5959

6060
Some(GsBorderRenderSideOptions {
@@ -66,7 +66,7 @@ impl<'a> GsBorderRenderOptions<'a> {
6666
})
6767
}
6868

69-
fn top(&self, transform: Option<&'a GsTransform>) -> Option<GsBorderRenderSideOptions> {
69+
fn top(&self, transform: Option<&'a GsTransform>) -> Option<GsBorderRenderSideOptions<'_>> {
7070
let segment = self.border.border.top.as_ref()?;
7171

7272
Some(GsBorderRenderSideOptions {
@@ -78,7 +78,7 @@ impl<'a> GsBorderRenderOptions<'a> {
7878
})
7979
}
8080

81-
fn bottom(&self, transform: Option<&'a GsTransform>) -> Option<GsBorderRenderSideOptions> {
81+
fn bottom(&self, transform: Option<&'a GsTransform>) -> Option<GsBorderRenderSideOptions<'_>> {
8282
let segment = self.border.border.bottom.as_ref()?;
8383

8484
Some(GsBorderRenderSideOptions {
@@ -117,7 +117,7 @@ impl GsBorder {
117117
}
118118

119119
fn draw_side(_scene: &mut Scene, opts: GsBorderRenderSideOptions) {
120-
let border_width = opts.segment.width as f64;
120+
let border_width = f64::from(opts.segment.width);
121121
let _brush = &opts.segment.brush;
122122
let style = opts.segment.style;
123123
let radius = opts.radius;
@@ -131,62 +131,68 @@ impl GsBorder {
131131

132132
match opts.side {
133133
GsSide::Top => {
134-
match radius {
135-
Some((left, right)) => {
136-
let offset_left = left.offset();
137-
let offset_right = right.offset();
138-
139-
path.move_to((pos.x - offset_left.width as f64, pos.y - offset_left.height as f64));
140-
141-
let arc = Arc {
142-
center: Point::new(pos.x + offset_left.width as f64, pos.y - offset_left.height as f64),
143-
radii: Vec2::new(left.radii_f64().0, left.radii_f64().1),
144-
start_angle: -std::f64::consts::PI * 3.0 / 4.0,
145-
sweep_angle: std::f64::consts::PI / 4.0,
146-
x_rotation: 0.0,
147-
};
148-
149-
arc.to_cubic_beziers(0.1, |p1, p2, p3| {
150-
path.curve_to(p1, p2, p3);
151-
});
152-
153-
path.line_to((
154-
pos.x + width - right.radi_x() as f64,
155-
pos.y - offset_right.height as f64,
156-
));
157-
158-
let arc = Arc {
159-
center: Point::new(pos.x + width - right.radi_x() as f64, pos.y + right.radi_y() as f64),
160-
radii: Vec2::new(right.radii_f64().0, right.radii_f64().1),
161-
start_angle: 0.0,
162-
sweep_angle: std::f64::consts::PI / 4.0,
163-
x_rotation: 0.0,
164-
};
165-
166-
arc.to_cubic_beziers(0.1, |p1, p2, p3| {
167-
path.curve_to(p1, p2, p3);
168-
});
169-
}
170-
None => {
171-
path.move_to((pos.x, pos.y));
172-
path.line_to((pos.x + width, pos.y));
173-
}
174-
};
134+
if let Some((left, right)) = radius {
135+
let offset_left = left.offset();
136+
let offset_right = right.offset();
137+
138+
path.move_to((
139+
pos.x - f64::from(offset_left.width),
140+
pos.y - f64::from(offset_left.height),
141+
));
142+
143+
let arc = Arc {
144+
center: Point::new(
145+
pos.x + f64::from(offset_left.width),
146+
pos.y - f64::from(offset_left.height),
147+
),
148+
radii: Vec2::new(left.radii_f64().0, left.radii_f64().1),
149+
start_angle: -std::f64::consts::PI * 3.0 / 4.0,
150+
sweep_angle: std::f64::consts::PI / 4.0,
151+
x_rotation: 0.0,
152+
};
153+
154+
arc.to_cubic_beziers(0.1, |p1, p2, p3| {
155+
path.curve_to(p1, p2, p3);
156+
});
157+
158+
path.line_to((
159+
pos.x + width - f64::from(right.radi_x()),
160+
pos.y - f64::from(offset_right.height),
161+
));
162+
163+
let arc = Arc {
164+
center: Point::new(
165+
pos.x + width - f64::from(right.radi_x()),
166+
pos.y + f64::from(right.radi_y()),
167+
),
168+
radii: Vec2::new(right.radii_f64().0, right.radii_f64().1),
169+
start_angle: 0.0,
170+
sweep_angle: std::f64::consts::PI / 4.0,
171+
x_rotation: 0.0,
172+
};
173+
174+
arc.to_cubic_beziers(0.1, |p1, p2, p3| {
175+
path.curve_to(p1, p2, p3);
176+
});
177+
} else {
178+
path.move_to((pos.x, pos.y));
179+
path.line_to((pos.x + width, pos.y));
180+
}
175181
}
176-
GsSide::Right => match radius {
177-
Some((top, bottom)) => {
182+
GsSide::Right => {
183+
if let Some((top, bottom)) = radius {
178184
let offset_top = top.offset();
179185
let offset_bottom = bottom.offset();
180186

181187
path.move_to((
182-
pos.x + width + offset_top.width as f64,
183-
pos.y - offset_top.height as f64,
188+
pos.x + width + f64::from(offset_top.width),
189+
pos.y - f64::from(offset_top.height),
184190
));
185191

186192
let arc = Arc {
187193
center: Point::new(
188-
pos.x + width - offset_top.width as f64,
189-
pos.y + offset_top.height as f64,
194+
pos.x + width - f64::from(offset_top.width),
195+
pos.y + f64::from(offset_top.height),
190196
),
191197
radii: Vec2::new(top.radii_f64().0, top.radii_f64().1),
192198
start_angle: -std::f64::consts::PI / 4.0,
@@ -199,14 +205,14 @@ impl GsBorder {
199205
});
200206

201207
path.line_to((
202-
pos.x + width - offset_bottom.width as f64,
203-
pos.y + height - bottom.radi_y() as f64,
208+
pos.x + width - f64::from(offset_bottom.width),
209+
pos.y + height - f64::from(bottom.radi_y()),
204210
));
205211

206212
let arc = Arc {
207213
center: Point::new(
208-
pos.x + width - offset_bottom.width as f64,
209-
pos.y + height - offset_bottom.height as f64,
214+
pos.x + width - f64::from(offset_bottom.width),
215+
pos.y + height - f64::from(offset_bottom.height),
210216
),
211217
radii: Vec2::new(bottom.radii_f64().0, bottom.radii_f64().1),
212218
start_angle: 0.0,
@@ -217,26 +223,25 @@ impl GsBorder {
217223
arc.to_cubic_beziers(0.1, |p1, p2, p3| {
218224
path.curve_to(p1, p2, p3);
219225
});
220-
}
221-
None => {
226+
} else {
222227
path.move_to((pos.x + width, pos.y));
223228
path.line_to((pos.x + width, pos.y + height));
224229
}
225-
},
226-
GsSide::Bottom => match radius {
227-
Some((left, right)) => {
230+
}
231+
GsSide::Bottom => {
232+
if let Some((left, right)) = radius {
228233
let offset_left = left.offset();
229234
let offset_right = right.offset();
230235

231236
path.move_to((
232-
pos.x + width + offset_right.width as f64,
233-
pos.y + height + offset_right.height as f64,
237+
pos.x + width + f64::from(offset_right.width),
238+
pos.y + height + f64::from(offset_right.height),
234239
));
235240

236241
let arc = Arc {
237242
center: Point::new(
238-
pos.x + width - offset_right.width as f64,
239-
pos.y + height - offset_right.height as f64,
243+
pos.x + width - f64::from(offset_right.width),
244+
pos.y + height - f64::from(offset_right.height),
240245
),
241246
radii: Vec2::new(right.radii_f64().0, right.radii_f64().1),
242247
start_angle: -std::f64::consts::PI * 7.0 / 4.0,
@@ -248,10 +253,16 @@ impl GsBorder {
248253
path.curve_to(p1, p2, p3);
249254
});
250255

251-
path.line_to((pos.x + left.radi_x() as f64, pos.y + height - offset_left.height as f64));
256+
path.line_to((
257+
pos.x + f64::from(left.radi_x()),
258+
pos.y + height - f64::from(offset_left.height),
259+
));
252260

253261
let arc = Arc {
254-
center: Point::new(pos.x + left.radi_x() as f64, pos.y + height - offset_left.height as f64),
262+
center: Point::new(
263+
pos.x + f64::from(left.radi_x()),
264+
pos.y + height - f64::from(offset_left.height),
265+
),
255266
radii: Vec2::new(left.radii_f64().0, left.radii_f64().1),
256267
start_angle: -std::f64::consts::PI * 3.0 / 2.0,
257268
sweep_angle: std::f64::consts::PI / 4.0,
@@ -261,26 +272,25 @@ impl GsBorder {
261272
arc.to_cubic_beziers(0.1, |p1, p2, p3| {
262273
path.curve_to(p1, p2, p3);
263274
});
264-
}
265-
None => {
275+
} else {
266276
path.move_to((pos.x, pos.y + height));
267277
path.line_to((pos.x + width, pos.y + height));
268278
}
269-
},
270-
GsSide::Left => match radius {
271-
Some((top, bottom)) => {
279+
}
280+
GsSide::Left => {
281+
if let Some((top, bottom)) = radius {
272282
let offset_top = top.offset();
273283
let offset_bottom = bottom.offset();
274284

275285
path.move_to((
276-
pos.x - offset_top.width as f64,
277-
pos.y + height + offset_top.height as f64,
286+
pos.x - f64::from(offset_top.width),
287+
pos.y + height + f64::from(offset_top.height),
278288
));
279289

280290
let arc = Arc {
281291
center: Point::new(
282-
pos.x + offset_top.width as f64,
283-
pos.y + height - offset_top.height as f64,
292+
pos.x + f64::from(offset_top.width),
293+
pos.y + height - f64::from(offset_top.height),
284294
),
285295
radii: Vec2::new(top.radii_f64().0, top.radii_f64().1),
286296
start_angle: -std::f64::consts::PI * 5.0 / 4.0,
@@ -292,10 +302,16 @@ impl GsBorder {
292302
path.curve_to(p1, p2, p3);
293303
});
294304

295-
path.line_to((pos.x + offset_bottom.width as f64, pos.y + bottom.radi_y() as f64));
305+
path.line_to((
306+
pos.x + f64::from(offset_bottom.width),
307+
pos.y + f64::from(bottom.radi_y()),
308+
));
296309

297310
let arc = Arc {
298-
center: Point::new(pos.x + offset_bottom.width as f64, pos.y + bottom.radi_y() as f64),
311+
center: Point::new(
312+
pos.x + f64::from(offset_bottom.width),
313+
pos.y + f64::from(bottom.radi_y()),
314+
),
299315
radii: Vec2::new(bottom.radii_f64().0, bottom.radii_f64().1),
300316
start_angle: -std::f64::consts::PI,
301317
sweep_angle: std::f64::consts::PI / 4.0,
@@ -305,12 +321,11 @@ impl GsBorder {
305321
arc.to_cubic_beziers(0.1, |p1, p2, p3| {
306322
path.curve_to(p1, p2, p3);
307323
});
308-
}
309-
None => {
324+
} else {
310325
path.move_to((pos.x, pos.y + height));
311326
path.line_to((pos.x, pos.y));
312327
}
313-
},
328+
}
314329
}
315330

316331
let cap = match style {

crates/gosub_cairo/src/elements/gradient.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl TGradient<CairoBackend> for GsGradient {
6262
fn to_stop_vec(stops: ColorStops<CairoBackend>) -> SmallVec<[ColorStop; 4]> {
6363
let mut vec = SmallVec::<[ColorStop; 4]>::new();
6464

65-
for stop in stops.iter() {
65+
for stop in &stops {
6666
let alpha_color = AlphaColor::<Srgb>::new([
6767
stop.color.r as f32,
6868
stop.color.g as f32,

crates/gosub_cairo/src/elements/rect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl GsRect {
4848

4949
impl TRect for GsRect {
5050
fn new(x: FP, y: FP, width: FP, height: FP) -> Self {
51-
GsRect::new(x as f64, y as f64, width as f64, height as f64, None)
51+
GsRect::new(f64::from(x), f64::from(y), f64::from(width), f64::from(height), None)
5252
}
5353

5454
fn from_point(point: Point, size: Size) -> Self {

0 commit comments

Comments
 (0)