chiark / gitweb /
subst: Promote PerhapsSubst
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 15 May 2022 08:24:32 +0000 (09:24 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 15 May 2022 11:37:03 +0000 (12:37 +0100)
I thought we wanted this for sorts.  I find we don't, but I don't want
to drop this change and deal with the conflicts.  I will revert it
later.  Much later.

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

index 9260c16159273aad594f28a8f480df90e11654e3..c59164a2f992acaa341e7f657f21b434a8fb8a29 100644 (file)
@@ -1093,6 +1093,24 @@ fn format_item_name(item_prefix: &str, fe: &FileData, item_suffix: &str)
     .try_into()?
 }
 
+#[derive(Debug)]
+enum PerhapsSubst<'i> {
+  Y(String),
+  N(&'i str),
+}
+
+impl<'i> PerhapsSubst<'i> {
+  #[throws(SubstError)]
+  pub fn finish(self) -> String { match self {
+    PerhapsSubst::N(s) => s.to_owned(),
+    PerhapsSubst::Y(s) => s,
+  } }
+  pub fn chain(&'i self) -> &'i str { match self {
+    PerhapsSubst::N(s) => s,
+    PerhapsSubst::Y(s) => s,
+  } }
+}
+
 #[throws(LibraryLoadError)]
 fn process_files_entry(
   src: &mut dyn LibrarySvgNoter, l: &mut Catalogue,
@@ -1136,24 +1154,6 @@ fn process_files_entry(
     },
   };
 
-  #[derive(Debug)]
-  enum PerhapsSubst<'i> {
-    Y(String),
-    N(&'i str),
-  }
-
-  impl<'i> PerhapsSubst<'i> {
-    #[throws(SubstError)]
-    pub fn finish(self) -> String { match self {
-      PerhapsSubst::N(s) => s.to_owned(),
-      PerhapsSubst::Y(s) => s,
-    } }
-    pub fn chain(&'i self) -> &'i str { match self {
-      PerhapsSubst::N(s) => s,
-      PerhapsSubst::Y(s) => s,
-    } }
-  }
-
   fn colour_subst_1<'s, S>(subst: S, kv: Option<(&'static str, &'s str)>)
     -> impl for <'i> Fn(&'i str) -> Result<PerhapsSubst<'i>, SubstError> + 's
   where S: Fn(&str, &'static str, &str) -> Result<String, SubstError> + 's