From f6f6c3a6313b33b14191869b981d63a959851434 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 15 May 2022 09:24:32 +0100 Subject: [PATCH] subst: Promote PerhapsSubst 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 --- src/shapelib.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/shapelib.rs b/src/shapelib.rs index 9260c161..c59164a2 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -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, SubstError> + 's where S: Fn(&str, &'static str, &str) -> Result + 's -- 2.30.2