From: Ian Jackson Date: Sun, 15 May 2022 11:45:46 +0000 (+0100) Subject: subst: Provide Dollars::enabled X-Git-Tag: otter-1.1.0~125 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=016f452702b00da6ce38822efc400c3ab9de2573;p=otter.git subst: Provide Dollars::enabled Signed-off-by: Ian Jackson --- diff --git a/src/shapelib.rs b/src/shapelib.rs index 159e5951..ef46c23b 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -1057,12 +1057,7 @@ impl<'s> Substituting<'s> { }.s.into() } - fn do_dollars(&self) -> bool { - match self.dollars { - Dollars::Filename => false, - Dollars::Text => self.mformat >= 2, - } - } + fn do_dollars(&self) -> bool { self.dollars.enabled(self.mformat) } #[throws(SubstError)] /// Expand, but do not do final unescaping @@ -1082,6 +1077,15 @@ impl<'s> Substituting<'s> { } } +impl Dollars { + fn enabled(self, mformat: materials_format::Version) -> bool { + match self { + Dollars::Filename => false, + Dollars::Text => mformat >= 2, + } + } +} + #[throws(SubstError)] fn subst_general_precisely<'i>(input: &Substituting<'i>, needle: & str,