chiark / gitweb /
subst: Demote PerhapsSubst
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 15 May 2022 11:36:50 +0000 (12:36 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 15 May 2022 14:19:55 +0000 (15:19 +0100)
Reverts
  subst: Promote PerhapsSubst

We shouldn't do this for anything but colour specs.

And, really, we ought to do it only for the item name and not for the
other things, or the ${$} de-escaping is very confusing.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/shapelib.rs

index 9fa1c9c4724647da72617b4abaf436117cdfc26a..ce657ce44c53e4961b87af97aa5c5e6546d46951 100644 (file)
@@ -1189,36 +1189,6 @@ fn format_item_name(mformat: materials_format::Version,
   )
 }
 
-#[derive(Debug,From,Clone)]
-enum PerhapsSubst<'i> {
-  Y(Substituting<'i>),
-  N(&'i str),
-}
-impl<'i> From<&'i String> for PerhapsSubst<'i> {
-  fn from(s: &'i String) -> Self { (&**s).into() }
-}
-
-impl<'i> PerhapsSubst<'i> {
-  #[throws(SubstError)]
-  pub fn finish(self) -> String { match self {
-    PerhapsSubst::N(s) => s.to_owned(),
-    PerhapsSubst::Y(s) => s.finish()?,
-  } }
-  #[throws(SubstError)]
-  pub fn nest(self) -> String { match self {
-    PerhapsSubst::N(s) => s.to_owned(),
-    PerhapsSubst::Y(s) => s.nest()?,
-  } }
-  pub fn mky(
-    self,
-    mformat: materials_format::Version,
-    dollars: Dollars,
-  ) -> Substituting<'i> { match self {
-    PerhapsSubst::N(s) => Substituting::new(mformat, dollars, s),
-    PerhapsSubst::Y(s) => s,
-  } }
-}
-
 #[throws(LibraryLoadError)]
 fn process_files_entry(
   src: &mut dyn LibrarySvgNoter, l: &mut Catalogue,
@@ -1270,6 +1240,36 @@ fn process_files_entry(
     },
   };
 
+  #[derive(Debug,From,Clone)]
+  enum PerhapsSubst<'i> {
+    Y(Substituting<'i>),
+    N(&'i str),
+  }
+  impl<'i> From<&'i String> for PerhapsSubst<'i> {
+    fn from(s: &'i String) -> Self { (&**s).into() }
+  }
+
+  impl<'i> PerhapsSubst<'i> {
+    #[throws(SubstError)]
+    pub fn finish(self) -> String { match self {
+      PerhapsSubst::N(s) => s.to_owned(),
+      PerhapsSubst::Y(s) => s.finish()?,
+    } }
+    #[throws(SubstError)]
+    pub fn nest(self) -> String { match self {
+      PerhapsSubst::N(s) => s.to_owned(),
+      PerhapsSubst::Y(s) => s.nest()?,
+    } }
+    pub fn mky(
+      self,
+      mformat: materials_format::Version,
+      dollars: Dollars,
+    ) -> Substituting<'i> { match self {
+      PerhapsSubst::N(s) => Substituting::new(mformat, dollars, s),
+      PerhapsSubst::Y(s) => s,
+    } }
+  }
+
   fn colour_subst_1<'s, S>(
     mformat: materials_format::Version,
     subst: S, kv: Option<(&'static str, &'s str)>