From: Ian Jackson Date: Sun, 15 May 2022 08:24:32 +0000 (+0100) Subject: subst: Promote PerhapsSubst X-Git-Tag: otter-1.1.0~137 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=f6f6c3a6313b33b14191869b981d63a959851434;p=otter.git 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 --- 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