From 10bc1af0f4eb54a0db6a95b1617a0716f73ee28e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 21 Jul 2020 22:21:23 +0100 Subject: [PATCH] fix new_from_path --- src/pieces.rs | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/pieces.rs b/src/pieces.rs index 87d5ba8e..6674e35e 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -4,23 +4,16 @@ use crate::imports::*; type ColourMap = IndexVec; #[derive(Debug,Serialize,Deserialize)] -#[serde(try_from="SimpleShapeLoad")] struct SimpleShape { desc : String, path : String, - #[serde(skip)] scaled_path : String, approx_dia : Coord, colours : ColourMap, } -#[derive(Deserialize)] -#[serde(transparent)] -struct SimpleShapeLoad(SimpleShape); - const SELECT_SCALE : f64 = 1.1; - #[derive(Copy,Clone,Debug,Error)] pub enum SVGProcessingError { UnknownOperator, @@ -114,22 +107,12 @@ impl Piece for SimpleShape { } } -impl TryFrom for SimpleShape { - type Error = SVGProcessingError; - #[throws(SE)] - fn try_from(l: SimpleShapeLoad) -> SimpleShape { - let mut s = l.0; - s.scaled_path = svg_rescale_path(&s.path, SELECT_SCALE)?; - s - } -} - impl SimpleShape { fn new_from_path(desc: String, path: String, approx_dia: Coord, colours: ColourMap) -> Result,SE> { + let scaled_path = svg_rescale_path(&path, SELECT_SCALE)?; Ok(Box::new(SimpleShape { - scaled_path : Default::default(), - desc, approx_dia, path, colours, + scaled_path, desc, approx_dia, path, colours, })) } fn new_square(edgelen: Coord, colours: ColourMap) -> Result,SE> { -- 2.30.2