Skip to content

Commit 7024adc

Browse files
committed
Fix example and format code
1 parent aec8848 commit 7024adc

File tree

7 files changed

+17
-29
lines changed

7 files changed

+17
-29
lines changed

plotters-backend/src/rasterizer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// the question mark operator has a huge performance impact due to LLVM unable to handle it.
1111
// So the question is if this trick is still useful, or LLVM is smart enough to handle it since
1212
// then.
13-
//
13+
//
1414
// --
1515
// Original comment:
1616
//

plotters/examples/pie.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1212
let radius = 300.0;
1313
let sizes = vec![66.0, 33.0];
1414
let _rgba = RGBAColor(0, 50, 255, 1.0);
15-
let colors = vec![RGBColor(0, 50, 255), CYAN];
15+
let colors = vec![RGBColor(0, 50, 255).to_rgba(), CYAN.to_rgba()];
1616
let labels = vec!["Pizza", "Pacman"];
1717

1818
let mut pie = Pie::new(&center, &radius, &sizes, &colors, &labels);

plotters/src/chart/context/cartesian2d/draw_impl.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ impl<'a, DB: DrawingBackend, X: Ranged, Y: Ranged> ChartContext<'a, DB, Cartesia
119119
y1 = axis_range.end;
120120
}
121121

122-
area.draw(&PathElement::new(
123-
vec![(x0, y0), (x1, y1)],
124-
*axis_style,
125-
))?;
122+
area.draw(&PathElement::new(vec![(x0, y0), (x1, y1)], *axis_style))?;
126123
}
127124

128125
Ok(axis_range)

plotters/src/chart/series.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,7 @@ impl<'a, 'b, DB: DrawingBackend + 'a, CT: CoordTranslate> SeriesLabelStyle<'a, '
250250
continue;
251251
}
252252

253-
funcs.push(
254-
draw_func.unwrap_or(&|p: BackendCoord| EmptyElement::at(p).into_dyn()),
255-
);
253+
funcs.push(draw_func.unwrap_or(&|p: BackendCoord| EmptyElement::at(p).into_dyn()));
256254
label_element.push_line(label_text);
257255
}
258256

plotters/src/drawing/area.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl Rect {
8787
.map(|(a, b)| (*a, *b))
8888
.collect();
8989

90-
// Justify: this is actually needed. Because we need to return a iterator that have
90+
// Justify: this is actually needed. Because we need to return a iterator that have
9191
// static life time, thus we need to copy the value to a buffer and then turn the buffer
9292
// into a iterator.
9393
#[allow(clippy::needless_collect)]
@@ -97,14 +97,12 @@ impl Rect {
9797
.map(|(a, b)| (*a, *b))
9898
.collect();
9999

100-
ysegs
101-
.into_iter()
102-
.flat_map(move |(y0, y1)| {
103-
xsegs
104-
.clone()
105-
.into_iter()
106-
.map(move |(x0, x1)| Self { x0, y0, x1, y1 })
107-
})
100+
ysegs.into_iter().flat_map(move |(y0, y1)| {
101+
xsegs
102+
.clone()
103+
.into_iter()
104+
.map(move |(x0, x1)| Self { x0, y0, x1, y1 })
105+
})
108106
}
109107

110108
/// Make the coordinate in the range of the rectangle

plotters/src/element/pie.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,14 @@ impl<'a, DB: DrawingBackend, Label: Display> Drawable<DB> for Pie<'a, (i32, i32)
109109
let radian_increment = PI / 180.0 / self.radius.sqrt() * 2.0;
110110
let mut perc_labels = Vec::new();
111111
for (index, slice) in self.sizes.iter().enumerate() {
112-
let slice_style =
113-
self.colors
114-
.get(index)
115-
.ok_or_else(|| DrawingErrorKind::FontError(Box::new(
116-
PieError::LengthMismatch,
117-
)))?;
112+
let slice_style = self
113+
.colors
114+
.get(index)
115+
.ok_or_else(|| DrawingErrorKind::FontError(Box::new(PieError::LengthMismatch)))?;
118116
let label = self
119117
.labels
120118
.get(index)
121-
.ok_or_else(|| DrawingErrorKind::FontError(Box::new(
122-
PieError::LengthMismatch,
123-
)))?;
119+
.ok_or_else(|| DrawingErrorKind::FontError(Box::new(PieError::LengthMismatch)))?;
124120
// start building wedge line against the previous edge
125121
let mut points = vec![*self.center];
126122
let ratio = slice / self.total;

plotters/src/series/line_series.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ impl<DB: DrawingBackend, Coord: Clone + 'static> Iterator for LineSeries<DB, Coo
4545
let idx = self.point_idx;
4646
self.point_idx += 1;
4747
return Some(
48-
Circle::new(self.data[idx].clone(), self.point_size, self.style)
49-
.into_dyn(),
48+
Circle::new(self.data[idx].clone(), self.point_size, self.style).into_dyn(),
5049
);
5150
}
5251
let mut data = vec![];

0 commit comments

Comments
 (0)