gdritter repos gunpowder_treason / db72b16
Add some backwards-compat in here Getty Ritter 5 years ago
1 changed file(s) with 6 addition(s) and 6 deletion(s). Collapse all Expand all
44
55 /// An SVG document
66 pub struct SVG {
7 stuff: Vec<Box<dyn AsSVG>>,
7 stuff: Vec<Box<AsSVG>>,
88 size: (f64, f64),
99 }
1010
2020
2121 fn inches(amt: f64) -> Inches { Inches { amt } }
2222
23 fn xml_tag(w: &mut Vec<u8>, name: &str, attrs: &[(&str, &dyn Display)]) {
23 fn xml_tag(w: &mut Vec<u8>, name: &str, attrs: &[(&str, &Display)]) {
2424 write!(w, "<{}", name);
25 for (k, v) in attrs {
25 for &(k, v) in attrs {
2626 write!(w, " {}=\"{}\"", k, v);
2727 }
2828 writeln!(w, "/>");
2929 }
3030
31 fn xml_open(w: &mut Vec<u8>, name: &str, attrs: &[(&str, &dyn Display)]) {
31 fn xml_open(w: &mut Vec<u8>, name: &str, attrs: &[(&str, &Display)]) {
3232 write!(w, "<{}", name);
33 for (k, v) in attrs {
33 for &(k, v) in attrs {
3434 write!(w, " {}=\"{}\"", k, v);
3535 }
3636 writeln!(w, ">");
132132 let mut path = Vec::new();
133133 let (x, y) = self.start;
134134 write!(&mut path, "M{} {}", x, y);
135 for (x, y) in self.points.iter() {
135 for &(x, y) in self.points.iter() {
136136 write!(&mut path, " L{} {}", x, y);
137137 }
138138 String::from_utf8(path).unwrap()