Skip to content

Commit 426e73b

Browse files
fix opacity and fill mixup in draw_pixel; address some clippy lints
1 parent 627a18d commit 426e73b

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

plotters-svg/src/svg.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ macro_rules! impl_format_escaped_tuple {
8888
{
8989
fn format_escaped(buf: &mut String, tup: Self) {
9090
$(
91-
let _ = FormatEscaped::format_escaped(buf, tup.$idx);
91+
FormatEscaped::format_escaped(buf, tup.$idx);
9292
)+
9393
}
9494
}
@@ -133,10 +133,10 @@ impl<T: FormatEscaped> FormatEscaped for Option<T> {
133133
fn format_escaped(buf: &mut String, opt: Option<T>) {
134134
match opt {
135135
None => {
136-
let _ = FormatEscaped::format_escaped(buf, "none");
136+
FormatEscaped::format_escaped(buf, "none");
137137
}
138138
Some(x) => {
139-
let _ = FormatEscaped::format_escaped(buf, x);
139+
FormatEscaped::format_escaped(buf, x);
140140
}
141141
}
142142
}
@@ -198,7 +198,7 @@ impl<'a> AttrWriter<'a, Init> {
198198
AttrWriter {
199199
buf: self.buf,
200200
tag: self.tag.clone(),
201-
tag_stack: &mut self.tag_stack,
201+
tag_stack: self.tag_stack,
202202
state: Default::default(),
203203
}
204204
}
@@ -223,14 +223,9 @@ impl<'a> AttrWriter<'a, Value> {
223223

224224
impl<'a> SVGBackend<'a> {
225225
fn escape_and_push(buf: &mut String, value: &str) {
226-
value.chars().for_each(|c| match c {
227-
'<' => buf.push_str("&lt;"),
228-
'>' => buf.push_str("&gt;"),
229-
'&' => buf.push_str("&amp;"),
230-
'"' => buf.push_str("&quot;"),
231-
'\'' => buf.push_str("&apos;"),
232-
other => buf.push(other),
233-
});
226+
value
227+
.chars()
228+
.for_each(|c| FormatEscaped::format_escaped(buf, c));
234229
}
235230

236231
fn close_tag(&mut self) -> bool {
@@ -245,7 +240,7 @@ impl<'a> SVGBackend<'a> {
245240
}
246241

247242
/// Opens a tag and provides facilities for writing attrs and closing the tag
248-
fn open_tag<'s>(&'s mut self, tag: SVGTag) -> AttrWriter<'s, Init> {
243+
fn open_tag(&mut self, tag: SVGTag) -> AttrWriter<'_, Init> {
249244
AttrWriter::open_tag(self.target.get_mut(), tag, &mut self.tag_stack)
250245
}
251246

@@ -356,10 +351,10 @@ impl<'a> DrawingBackend for SVGBackend<'a> {
356351
attrwriter.write_key("width").write_value("1");
357352
attrwriter.write_key("height").write_value("1");
358353
attrwriter.write_key("stroke").write_value("none");
354+
attrwriter.write_key("opacity").write_value(color.alpha);
359355
attrwriter
360-
.write_key("opacity")
356+
.write_key("fill")
361357
.write_value(make_svg_color(color));
362-
attrwriter.write_key("fill").write_value(color.alpha);
363358
attrwriter.close();
364359
Ok(())
365360
}

0 commit comments

Comments
 (0)