Skip to content

Commit e0ac322

Browse files
committed
clippy
1 parent 06c8a25 commit e0ac322

File tree

4 files changed

+37
-26
lines changed

4 files changed

+37
-26
lines changed

src/function.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@ impl Style {
3737
}
3838

3939
pub fn overlay(&mut self, other: &Self) {
40-
match other.colour {
41-
Some(ref v) => self.colour = Some(v.clone()),
42-
None => {}
40+
if let Some(ref v) = other.colour {
41+
self.colour = Some(v.clone())
4342
}
4443

45-
match other.width {
46-
Some(ref v) => self.width = Some(v.clone()),
47-
None => {}
44+
if let Some(ref v) = other.width {
45+
self.width = Some(v.clone())
4846
}
4947
}
5048
}
@@ -97,7 +95,7 @@ impl Function {
9795
}
9896

9997
pub fn style(mut self, style: &Style) -> Self {
100-
self.style.overlay(&style);
98+
self.style.overlay(style);
10199
self
102100
}
103101

src/histogram.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ impl Style {
4040
}
4141

4242
pub fn overlay(&mut self, other: &Self) {
43-
match other.fill {
44-
Some(ref v) => self.fill = Some(v.clone()),
45-
None => {}
43+
if let Some(ref v) = other.fill {
44+
self.fill = Some(v.clone())
4645
}
4746
}
4847
}
@@ -136,7 +135,7 @@ impl Histogram {
136135
}
137136

138137
pub fn style(mut self, style: &Style) -> Self {
139-
self.style.overlay(&style);
138+
self.style.overlay(style);
140139
self
141140
}
142141

src/scatter.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,16 @@ impl Style {
3030
}
3131

3232
pub fn overlay(&mut self, other: &Self) {
33-
match other.marker {
34-
Some(ref v) => self.marker = Some(v.clone()),
35-
None => {}
33+
if let Some(ref v) = other.marker {
34+
self.marker = Some(v.clone())
3635
}
37-
match other.colour {
38-
Some(ref v) => self.colour = Some(v.clone()),
39-
None => {}
36+
37+
if let Some(ref v) = other.colour {
38+
self.colour = Some(v.clone())
4039
}
41-
match other.size {
42-
Some(ref v) => self.size = Some(v.clone()),
43-
None => {}
40+
41+
if let Some(ref v) = other.size {
42+
self.size = Some(v.clone())
4443
}
4544
}
4645
}
@@ -105,7 +104,7 @@ impl Scatter {
105104
}
106105

107106
pub fn style(mut self, style: &Style) -> Self {
108-
self.style.overlay(&style);
107+
self.style.overlay(style);
109108
self
110109
}
111110

src/svg_render.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ where
134134
.set("cx", x_pos)
135135
.set("cy", y_pos)
136136
.set("r", radius)
137-
.set("fill", style.get_colour().clone().unwrap_or("".into())),
137+
.set(
138+
"fill",
139+
style.get_colour().clone().unwrap_or_else(|| "".into()),
140+
),
138141
);
139142
}
140143
style::Marker::Square => {
@@ -144,7 +147,10 @@ where
144147
.set("y", y_pos - radius)
145148
.set("width", 2. * radius)
146149
.set("height", 2. * radius)
147-
.set("fill", style.get_colour().clone().unwrap_or("".into())),
150+
.set(
151+
"fill",
152+
style.get_colour().clone().unwrap_or_else(|| "".into()),
153+
),
148154
);
149155
}
150156
style::Marker::Cross => {
@@ -157,7 +163,10 @@ where
157163
group.append(
158164
node::element::Path::new()
159165
.set("fill", "none")
160-
.set("stroke", style.get_colour().clone().unwrap_or("".into()))
166+
.set(
167+
"stroke",
168+
style.get_colour().clone().unwrap_or_else(|| "".into()),
169+
)
161170
.set("stroke-width", 2)
162171
.set("d", path),
163172
);
@@ -193,7 +202,10 @@ where
193202
.set("height", count_scaled)
194203
.set(
195204
"fill",
196-
style.get_fill().clone().unwrap_or("burlywood".into()),
205+
style
206+
.get_fill()
207+
.clone()
208+
.unwrap_or_else(|| "burlywood".into()),
197209
)
198210
.set("stroke", "black");
199211
group.append(rect);
@@ -237,7 +249,10 @@ where
237249
group.append(
238250
node::element::Path::new()
239251
.set("fill", "none")
240-
.set("stroke", style.get_colour().clone().unwrap_or("".into()))
252+
.set(
253+
"stroke",
254+
style.get_colour().clone().unwrap_or_else(|| "".into()),
255+
)
241256
.set("stroke-width", style.get_width().clone().unwrap_or(2.))
242257
.set("d", path),
243258
);

0 commit comments

Comments
 (0)