From: Ian Jackson Date: Sat, 13 Feb 2021 01:28:19 +0000 (+0000) Subject: SimpleShape: svg_piece: Refator to use more write! X-Git-Tag: otter-0.4.0~526 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=9c4e1e62d327a8384ca0c42f438b78623ded7eac;p=otter.git SimpleShape: svg_piece: Refator to use more write! NFC Signed-off-by: Ian Jackson --- diff --git a/src/pieces.rs b/src/pieces.rs index 7012cbc8..727141ef 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -123,11 +123,11 @@ impl Piece for SimpleShape { #[throws(IE)] fn svg_piece(&self, f: &mut Html, pri: &PieceRenderInstructions) { let f = &mut f.0; - let ef = |cmap: &ColourMap, attrname: &str, otherwise: &str| { + let ef = |f: &mut String, cmap: &ColourMap, attrname: &str, otherwise| { if let Some(colour) = cmap.get(pri.face) { - format!(r##"{}="{}""##, attrname, colour.0) + write!(f, r##"{}="{}""##, attrname, colour.0) } else { - otherwise.to_owned() + write!(f, "{}", otherwise) } }; if self.colours.len() == 0 { @@ -136,10 +136,10 @@ impl Piece for SimpleShape { stroke-width="2" stroke="transparent" d="{}"/>"##, &self.path.0)?; } - write!(f, r##""##, - ef(&self.colours, "fill", r##"fill="none""##), - ef(&self.edges, r##"stroke-width="0.2" stroke"##, ""), - &self.path.0)?; + write!(f, r##""##, &self.path.0)?; } fn describe_html(&self, face: Option) -> Html { Html(if_chain! {