From 9c337859ce47ea3dda2df90e5d861bc1cef18e57 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 22 Mar 2021 01:52:08 +0000 Subject: [PATCH] shapelib refactoring: Make OccData an enum But we want to transpose with the Arc Signed-off-by: Ian Jackson --- src/shapelib.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/shapelib.rs b/src/shapelib.rs index 60fa6ab7..c6708830 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -51,7 +51,13 @@ struct ItemData { } #[derive(Debug)] -struct OccData { +enum OccData { + Internal(OccData_Internal), +} + +#[allow(non_camel_case_types)] +#[derive(Debug)] +struct OccData_Internal { item_name: Arc, outline: Outline, desc: Html, @@ -385,9 +391,9 @@ impl Contents { } faces.shrink_to_fit(); - let occultable = match &idata.occ { + let occultable = match idata.occ.as_ref().map(Deref::deref) { None => None, - Some(occ) => { + Some(OccData::Internal(occ)) => { let name = occ.item_name.clone(); let svgd = { let mut svgd = occ.svgd.lock(); @@ -574,13 +580,13 @@ fn load_catalogue(libname: &str, dirname: &str, toml_path: &str) -> Contents { if ! group.d.colours.contains_key(colour.as_str()) { throw!(LLE::OccultationColourMissing(colour.clone())); } - Some(Arc::new(OccData { + Some(Arc::new(OccData::Internal(OccData_Internal { item_name: Arc::new(subst(&item_name, "_c", &colour)?), desc: Html(subst(&fe.desc.0, "_colour", "")?), outline: outline.clone(), xform: FaceTransform::from_group(&group.d)?, svgd: default(), - })) + }))) }, }; -- 2.30.2