Skip to content

Commit fbfefd6

Browse files
committed
take donut_hole by value
1 parent 805c75b commit fbfefd6

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

plotters/src/element/pie.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct Pie<'a, Coord, Label: Display> {
3131
label_style: TextStyle<'a>,
3232
label_offset: f64,
3333
percentage_style: Option<TextStyle<'a>>,
34-
donut_hole: &'a f64, // radius of the hole in case of a donut chart
34+
donut_hole: f64, // radius of the hole in case of a donut chart
3535
}
3636

3737
impl<'a, Label: Display> Pie<'a, (i32, i32), Label> {
@@ -63,7 +63,7 @@ impl<'a, Label: Display> Pie<'a, (i32, i32), Label> {
6363
label_style,
6464
label_offset: radius_5pct,
6565
percentage_style: None,
66-
donut_hole: &0.0,
66+
donut_hole: 0.0,
6767
}
6868
}
6969

@@ -97,8 +97,8 @@ impl<'a, Label: Display> Pie<'a, (i32, i32), Label> {
9797
/// Enables creating a donut chart with a hole of the specified radius.
9898
///
9999
/// The passed value must be greater than zero and lower than the chart overall radius, otherwise it'll be ignored.
100-
pub fn donut_hole(&mut self, hole_radius: &'a f64) {
101-
if hole_radius > &0.0 && hole_radius < self.radius {
100+
pub fn donut_hole(&mut self, hole_radius: f64) {
101+
if hole_radius > 0.0 && hole_radius < *self.radius {
102102
self.donut_hole = hole_radius;
103103
}
104104
}
@@ -129,7 +129,7 @@ impl<'a, DB: DrawingBackend, Label: Display> Drawable<DB> for Pie<'a, (i32, i32)
129129
.get(index)
130130
.ok_or_else(|| DrawingErrorKind::FontError(Box::new(PieError::LengthMismatch)))?;
131131
// start building wedge line against the previous edge
132-
let mut points = if self.donut_hole == &0.0 {
132+
let mut points = if self.donut_hole == 0.0 {
133133
vec![*self.center]
134134
} else {
135135
vec![]
@@ -152,15 +152,15 @@ impl<'a, DB: DrawingBackend, Label: Display> Drawable<DB> for Pie<'a, (i32, i32)
152152
points.push(coord);
153153
offset_theta += radian_increment;
154154
}
155-
if self.donut_hole > &0.0 {
155+
if self.donut_hole > 0.0 {
156156
while offset_theta >= slice_start {
157-
let coord = theta_to_ordinal_coord(*self.donut_hole, offset_theta, self.center);
157+
let coord = theta_to_ordinal_coord(self.donut_hole, offset_theta, self.center);
158158
points.push(coord);
159159
offset_theta -= radian_increment;
160160
}
161161
}
162162
// final point of the wedge may not fall exactly on a radian, so add it extra
163-
if self.donut_hole == &0.0 {
163+
if self.donut_hole == 0.0 {
164164
let final_coord = theta_to_ordinal_coord(*self.radius, theta_final, self.center);
165165
points.push(final_coord);
166166
}
@@ -189,7 +189,7 @@ impl<'a, DB: DrawingBackend, Label: Display> Drawable<DB> for Pie<'a, (i32, i32)
189189
let label_size = backend.estimate_text_size(&perc_label, percentage_style)?;
190190
let text_x_mid = (label_size.0 as f64 / 2.0).round() as i32;
191191
let text_y_mid = (label_size.1 as f64 / 2.0).round() as i32;
192-
let perc_radius = if self.donut_hole == &0.0 {
192+
let perc_radius = if self.donut_hole == 0.0 {
193193
self.radius / 2.0
194194
} else {
195195
(self.radius + self.donut_hole) / 2.0

0 commit comments

Comments
 (0)