Skip to content

Commit 48f8f0d

Browse files
committed
Refactor
1 parent 18dce90 commit 48f8f0d

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

src/chart/dual_coord.rs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ pub struct DualCoordChartState<CT1: CoordTranslate, CT2: CoordTranslate> {
3636
secondary: ChartState<CT2>,
3737
}
3838

39-
impl<'a, DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate>
40-
DualCoordChartContext<'a, DB, CT1, CT2>
39+
impl<DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate>
40+
DualCoordChartContext<'_, DB, CT1, CT2>
4141
{
4242
/// Convert the chart context into a chart state, similar to [ChartContext::into_chart_state](struct.ChartContext.html#method.into_chart_state)
4343
pub fn into_chart_state(self) -> DualCoordChartState<CT1, CT2> {
@@ -54,16 +54,13 @@ impl<'a, DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate>
5454
secondary: self.secondary.into_shared_chart_state(),
5555
}
5656
}
57-
}
5857

59-
impl<'a, DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate>
60-
DualCoordChartContext<'a, DB, CT1, CT2>
61-
where
62-
CT1: Clone,
63-
CT2: Clone,
64-
{
6558
/// Copy the coordinate specs and make a chart state
66-
pub fn to_chart_state(&self) -> DualCoordChartState<CT1, CT2> {
59+
pub fn to_chart_state(&self) -> DualCoordChartState<CT1, CT2>
60+
where
61+
CT1: Clone,
62+
CT2: Clone,
63+
{
6764
DualCoordChartState {
6865
primary: self.primary.to_chart_state(),
6966
secondary: self.secondary.to_chart_state(),
@@ -73,10 +70,10 @@ where
7370

7471
impl<CT1: CoordTranslate, CT2: CoordTranslate> DualCoordChartState<CT1, CT2> {
7572
/// Restore the chart state on the given drawing area
76-
pub fn restore<'a, DB: DrawingBackend + 'a>(
73+
pub fn restore<DB: DrawingBackend>(
7774
self,
7875
area: &DrawingArea<DB, Shift>,
79-
) -> DualCoordChartContext<'a, DB, CT1, CT2> {
76+
) -> DualCoordChartContext<'_, DB, CT1, CT2> {
8077
let primary = self.primary.restore(area);
8178
let secondary = self
8279
.secondary
@@ -85,18 +82,18 @@ impl<CT1: CoordTranslate, CT2: CoordTranslate> DualCoordChartState<CT1, CT2> {
8582
}
8683
}
8784

88-
impl<'a, DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate>
89-
From<DualCoordChartContext<'a, DB, CT1, CT2>> for DualCoordChartState<CT1, CT2>
85+
impl<DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate>
86+
From<DualCoordChartContext<'_, DB, CT1, CT2>> for DualCoordChartState<CT1, CT2>
9087
{
91-
fn from(chart: DualCoordChartContext<'a, DB, CT1, CT2>) -> DualCoordChartState<CT1, CT2> {
88+
fn from(chart: DualCoordChartContext<'_, DB, CT1, CT2>) -> DualCoordChartState<CT1, CT2> {
9289
chart.into_chart_state()
9390
}
9491
}
9592

96-
impl<'a, 'b, DB: DrawingBackend, CT1: CoordTranslate + Clone, CT2: CoordTranslate + Clone>
97-
From<&'b DualCoordChartContext<'a, DB, CT1, CT2>> for DualCoordChartState<CT1, CT2>
93+
impl<'b, DB: DrawingBackend, CT1: CoordTranslate + Clone, CT2: CoordTranslate + Clone>
94+
From<&'b DualCoordChartContext<'_, DB, CT1, CT2>> for DualCoordChartState<CT1, CT2>
9895
{
99-
fn from(chart: &'b DualCoordChartContext<'a, DB, CT1, CT2>) -> DualCoordChartState<CT1, CT2> {
96+
fn from(chart: &'b DualCoordChartContext<'_, DB, CT1, CT2>) -> DualCoordChartState<CT1, CT2> {
10097
chart.to_chart_state()
10198
}
10299
}
@@ -139,8 +136,8 @@ impl<'a, DB: DrawingBackend, CT1: CoordTranslate, CT2: CoordTranslate>
139136
}
140137
}
141138

142-
impl<'a, DB: DrawingBackend, CT1: CoordTranslate, CT2: ReverseCoordTranslate>
143-
DualCoordChartContext<'a, DB, CT1, CT2>
139+
impl<DB: DrawingBackend, CT1: CoordTranslate, CT2: ReverseCoordTranslate>
140+
DualCoordChartContext<'_, DB, CT1, CT2>
144141
{
145142
/// Convert the chart context into the secondary coordinate translation function
146143
pub fn into_secondary_coord_trans(self) -> impl Fn(BackendCoord) -> Option<CT2::From> {
@@ -149,8 +146,8 @@ impl<'a, DB: DrawingBackend, CT1: CoordTranslate, CT2: ReverseCoordTranslate>
149146
}
150147
}
151148

152-
impl<'a, DB: DrawingBackend, CT1: ReverseCoordTranslate, CT2: ReverseCoordTranslate>
153-
DualCoordChartContext<'a, DB, CT1, CT2>
149+
impl<DB: DrawingBackend, CT1: ReverseCoordTranslate, CT2: ReverseCoordTranslate>
150+
DualCoordChartContext<'_, DB, CT1, CT2>
154151
{
155152
/// Convert the chart context into a pair of closures that maps the pixel coordinate into the
156153
/// logical coordinate for both primary coordinate system and secondary coordinate system.

0 commit comments

Comments
 (0)