Skip to content

Commit 4021179

Browse files
committed
Cleanup clippy errors
1 parent 61e9fb7 commit 4021179

File tree

16 files changed

+49
-71
lines changed

16 files changed

+49
-71
lines changed

src/chart/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ impl<'a, 'b, DB: DrawingBackend> ChartBuilder<'a, 'b, DB> {
155155
self
156156
}
157157

158+
#[allow(clippy::type_complexity)]
158159
#[deprecated(
159160
note = "`build_ranged` has been renamed to `build_cartesian_2d` and is to be removed in the future."
160161
)]

src/chart/series.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ pub struct SeriesAnno<'a, DB: DrawingBackend> {
1717
}
1818

1919
impl<'a, DB: DrawingBackend> SeriesAnno<'a, DB> {
20+
#[allow(clippy::option_as_ref_deref)]
2021
pub(crate) fn get_label(&self) -> &str {
22+
// TODO: Change this when we bump the MSRV
2123
self.label.as_ref().map(|x| x.as_str()).unwrap_or("")
2224
}
2325

src/chart/state.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,13 @@ use plotters_backend::DrawingBackend;
3131
/// chart.plotting_area().fill(&WHITE).unwrap(); // Clear the previously drawn graph
3232
/// // At this point, you are able to draw next frame
3333
///```
34+
///#[derive(Clone)]
3435
pub struct ChartState<CT: CoordTranslate> {
3536
drawing_area_pos: (i32, i32),
3637
drawing_area_size: (u32, u32),
3738
coord: CT,
3839
}
3940

40-
impl<'a, CT: CoordTranslate + Clone> Clone for ChartState<CT> {
41-
fn clone(&self) -> Self {
42-
Self {
43-
drawing_area_size: self.drawing_area_size,
44-
drawing_area_pos: self.drawing_area_pos,
45-
coord: self.coord.clone(),
46-
}
47-
}
48-
}
49-
5041
impl<'a, DB: DrawingBackend, CT: CoordTranslate> From<ChartContext<'a, DB, CT>> for ChartState<CT> {
5142
fn from(chart: ChartContext<'a, DB, CT>) -> ChartState<CT> {
5243
ChartState {

src/coord/ranged1d/combinators/group_by.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ impl<T: DiscreteRanged> Ranged for GroupBy<T> {
9292
.collect();
9393
let size = self.0.size();
9494
return outter_ticks
95-
.into_iter()
9695
.map(|base| inner_ticks.iter().map(move |&ofs| base * self.1 + ofs))
9796
.flatten()
9897
.take_while(|&idx| idx < size)
@@ -101,7 +100,6 @@ impl<T: DiscreteRanged> Ranged for GroupBy<T> {
101100
}
102101

103102
idx_iter
104-
.into_iter()
105103
.map(|x| self.0.from_index(x * self.1).unwrap())
106104
.collect()
107105
}

src/coord/ranged1d/combinators/linspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ where
288288
}
289289

290290
fn key_points<Hint: KeyPointHint>(&self, hint: Hint) -> Vec<T::ValueType> {
291-
if self.grid_value.len() == 0 {
291+
if self.grid_value.is_empty() {
292292
return vec![];
293293
}
294294
let idx_range: RangedCoordusize = (0..(self.grid_value.len() - 1)).into();

src/coord/ranged1d/combinators/logarithmic.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,23 @@ impl_log_scalable!(i, u64);
4949
impl_log_scalable!(f, f32);
5050
impl_log_scalable!(f, f64);
5151

52-
/// The logarithmic coodinate decorator.
53-
/// This decorator is used to make the axis rendered as logarithmically.
54-
pub struct LogRange<V: LogScalable>(pub Range<V>);
52+
pub trait IntoLogRange {
53+
type ValueType: LogScalable;
54+
fn log_scale(self) -> LogRange<Self::ValueType>;
55+
}
5556

56-
impl<V: LogScalable + Clone> Clone for LogRange<V> {
57-
fn clone(&self) -> Self {
58-
Self(self.0.clone())
57+
impl<T: LogScalable> IntoLogRange for Range<T> {
58+
type ValueType = T;
59+
fn log_scale(self) -> LogRange<T> {
60+
LogRange(self)
5961
}
6062
}
6163

64+
/// The logarithmic coodinate decorator.
65+
/// This decorator is used to make the axis rendered as logarithmically.
66+
#[derive(Clone)]
67+
pub struct LogRange<V: LogScalable>(pub Range<V>);
68+
6269
impl<V: LogScalable> From<LogRange<V>> for LogCoord<V> {
6370
fn from(range: LogRange<V>) -> LogCoord<V> {
6471
LogCoord {

src/coord/ranged1d/combinators/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod linspace;
88
pub use linspace::{IntoLinspace, Linspace};
99

1010
mod logarithmic;
11-
pub use logarithmic::{LogCoord, LogRange, LogScalable};
11+
pub use logarithmic::{IntoLogRange, LogCoord, LogRange, LogScalable};
1212

1313
mod nested;
1414
pub use nested::{BuildNestedCoord, NestedRange, NestedValue};

src/coord/ranged1d/combinators/nested.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<P: DiscreteRanged, S: Ranged> Ranged for NestedRange<P, S> {
105105
self.primary
106106
.key_points(hint)
107107
.into_iter()
108-
.map(|x| NestedValue::Category(x))
108+
.map(NestedValue::Category)
109109
.collect()
110110
} else {
111111
let secondary_size =
@@ -176,10 +176,7 @@ where
176176
.map(|value| builder(value).into())
177177
.collect();
178178

179-
NestedRange {
180-
primary,
181-
secondary: secondary,
182-
}
179+
NestedRange { primary, secondary }
183180
}
184181
}
185182

src/coord/ranged1d/combinators/partial_axis.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::ops::Range;
66
/// This axis decorator will make the axis partially display on the axis.
77
/// At some time, we want the axis only covers some part of the value.
88
/// This decorator will have an additional display range defined.
9+
#[derive(Clone)]
910
pub struct PartialAxis<R: Ranged>(R, Range<R::ValueType>);
1011

1112
/// The trait for the types that can be converted into a partial axis
@@ -24,15 +25,6 @@ pub trait IntoPartialAxis: AsRangedCoord {
2425

2526
impl<R: AsRangedCoord> IntoPartialAxis for R {}
2627

27-
impl<R: Ranged + Clone> Clone for PartialAxis<R>
28-
where
29-
<R as Ranged>::ValueType: Clone,
30-
{
31-
fn clone(&self) -> Self {
32-
PartialAxis(self.0.clone(), self.1.clone())
33-
}
34-
}
35-
3628
impl<R: Ranged> Ranged for PartialAxis<R>
3729
where
3830
R::ValueType: Clone,

src/coord/ranged1d/discrete.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,9 @@ where
9191
/// This is used in histogram types, which uses a discrete coordinate as the buckets. The segmented coord always emits `CenterOf(value)` key points, thus it allows all the label and tick marks
9292
/// of the coordinate rendered in the middle of each segment.
9393
/// The coresponding trait [IntoSegmentedCoord](trait.IntoSegmentedCoord.html) is used to apply this decorator to coordinates.
94+
#[derive(Clone)]
9495
pub struct SegmentedCoord<D: DiscreteRanged>(D);
9596

96-
impl<D: DiscreteRanged + Clone> Clone for SegmentedCoord<D> {
97-
fn clone(&self) -> Self {
98-
SegmentedCoord(self.0.clone())
99-
}
100-
}
101-
10297
/// The trait for types that can decorated by [SegmentedCoord](struct.SegmentedCoord.html) decorator.
10398
pub trait IntoSegmentedCoord: AsRangedCoord
10499
where
@@ -191,12 +186,10 @@ impl<D: DiscreteRanged> DiscreteRanged for SegmentedCoord<D> {
191186
}
192187

193188
fn from_index(&self, idx: usize) -> Option<Self::ValueType> {
194-
if idx < self.0.size() {
195-
self.0.from_index(idx).map(|x| SegmentValue::Exact(x))
196-
} else if idx == self.0.size() {
197-
Some(SegmentValue::Last)
198-
} else {
199-
None
189+
match idx {
190+
idx if idx < self.0.size() => self.0.from_index(idx).map(SegmentValue::Exact),
191+
idx if idx == self.0.size() => Some(SegmentValue::Last),
192+
_ => None,
200193
}
201194
}
202195
}

0 commit comments

Comments
 (0)