From 016f452702b00da6ce38822efc400c3ab9de2573 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 15 May 2022 12:45:46 +0100 Subject: [PATCH] subst: Provide Dollars::enabled Signed-off-by: Ian Jackson --- src/shapelib.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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, -- 2.30.2