Skip to content

Commit 24bf063

Browse files
committed
Apply some clippy lints
1 parent f29a6e3 commit 24bf063

File tree

15 files changed

+27
-30
lines changed

15 files changed

+27
-30
lines changed

plotters-backend/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ pub trait DrawingBackend: Sized {
233233
.layout_box(text)
234234
.map_err(|e| DrawingErrorKind::FontError(Box::new(e)))?;
235235
let ((min_x, min_y), (max_x, max_y)) = layout;
236-
let width = (max_x - min_x) as i32;
237-
let height = (max_y - min_y) as i32;
236+
let width = max_x - min_x;
237+
let height = max_y - min_y;
238238
let dx = match style.anchor().h_pos {
239239
HPos::Left => 0,
240240
HPos::Right => -width,
@@ -247,15 +247,16 @@ pub trait DrawingBackend: Sized {
247247
};
248248
let trans = style.transform();
249249
let (w, h) = self.get_size();
250-
match style.draw(text, (0, 0), |x, y, color| {
250+
let drawing_result = style.draw(text, (0, 0), |x, y, color| {
251251
let (x, y) = trans.transform(x + dx - min_x, y + dy - min_y);
252252
let (x, y) = (pos.0 + x, pos.1 + y);
253253
if x >= 0 && x < w as i32 && y >= 0 && y < h as i32 {
254254
self.draw_pixel((x, y), color)
255255
} else {
256256
Ok(())
257257
}
258-
}) {
258+
});
259+
match drawing_result {
259260
Ok(drawing_result) => drawing_result,
260261
Err(font_error) => Err(DrawingErrorKind::FontError(Box::new(font_error))),
261262
}

plotters-backend/src/rasterizer/circle.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ fn draw_annulus<B: DrawingBackend, S: BackendStyle>(
168168
radius.0 as f64 - a0,
169169
a1.floor(),
170170
|h, (f, t)| {
171-
let h = h as i32;
172171
let f = f as i32;
173172
let t = t as i32;
174173
check_result!(b.draw_line(

plotters-backend/src/rasterizer/line.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub fn draw_line<DB: DrawingBackend, S: BackendStyle>(
110110
}
111111

112112
if to.0 > batch_limit && y < f64::from(to.1) {
113-
let x = batch_limit as i32 + 1;
113+
let x = batch_limit + 1;
114114
if 1.0 + y.floor() - y > 1e-5 {
115115
check_result!(put_pixel((x, y as i32), 1.0 + y.floor() - y));
116116
}

plotters-backend/src/rasterizer/path.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ pub fn polygonize(vertices: &[BackendCoord], stroke_width: u32) -> Vec<BackendCo
145145
}
146146

147147
#[cfg(test)]
148-
mod test
149-
{
148+
mod test {
150149
use super::*;
151150

152151
/// Test for regression with respect to https://github.com/plotters-rs/plotters/issues/562
@@ -168,6 +167,6 @@ mod test
168167
compute_polygon_vertex(&path, 2.0, buf.as_mut());
169168
assert!(!buf.is_empty());
170169
let buf2 = vec![(18, 12)];
171-
assert_eq!(buf,buf2);
170+
assert_eq!(buf, buf2);
172171
}
173-
}
172+
}

plotters-backend/src/text.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ pub mod text_anchor {
107107
pub fn new(h_pos: HPos, v_pos: VPos) -> Self {
108108
Pos { h_pos, v_pos }
109109
}
110-
111110
}
112111
}
113112

plotters-bitmap/src/bitmap/target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl<'a> Buffer<'a> {
2424
match self {
2525
#[cfg(all(not(target_arch = "wasm32"), feature = "image"))]
2626
Buffer::Owned(buf) => &mut buf[..],
27-
Buffer::Borrowed(buf) => *buf,
27+
Buffer::Borrowed(buf) => buf,
2828
}
2929
}
3030
}

plotters-svg/src/svg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ use std::path::Path;
1717

1818
fn make_svg_color(color: BackendColor) -> String {
1919
let (r, g, b) = color.rgb;
20-
return format!("#{:02X}{:02X}{:02X}", r, g, b);
20+
format!("#{:02X}{:02X}{:02X}", r, g, b)
2121
}
2222

2323
fn make_svg_opacity(color: BackendColor) -> String {
24-
return format!("{}", color.alpha);
24+
format!("{}", color.alpha)
2525
}
2626

2727
enum Target<'a> {

plotters/src/coord/ranged1d/combinators/group_by.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ impl<T: DiscreteRanged> Ranged for GroupBy<T> {
8585
let outer_ticks = idx_iter;
8686
let outer_tick_size = interval * self.1;
8787
let inner_ticks_per_group = hint.max_num_points() / outer_ticks.len();
88-
let inner_ticks =
89-
(outer_tick_size + inner_ticks_per_group - 1) / inner_ticks_per_group;
88+
let inner_ticks = (outer_tick_size + inner_ticks_per_group - 1) / inner_ticks_per_group;
9089
let inner_ticks: Vec<_> = (0..(outer_tick_size / inner_ticks))
9190
.map(move |x| x * inner_ticks)
9291
.collect();

plotters/src/coord/ranged1d/combinators/linspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ where
315315
}
316316

317317
fn from_index(&self, idx: usize) -> Option<T::ValueType> {
318-
self.grid_value.get(idx).map(Clone::clone)
318+
self.grid_value.get(idx).cloned()
319319
}
320320
}
321321

plotters/src/coord/ranged1d/types/datetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ impl Ranged for RangedDuration {
779779

780780
while current < self.1 {
781781
ret.push(current);
782-
current = current + Duration::nanoseconds(period as i64);
782+
current += Duration::nanoseconds(period as i64);
783783
}
784784

785785
return ret;
@@ -818,7 +818,7 @@ impl Ranged for RangedDuration {
818818

819819
while current < self.1 {
820820
ret.push(current);
821-
current = current + Duration::days(i64::from(days_per_tick));
821+
current += Duration::days(i64::from(days_per_tick));
822822
}
823823

824824
ret

0 commit comments

Comments
 (0)