From 5fcf9878d34e1ae1e9c7e9133737d71bff1aa0d8 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 2 May 2022 11:35:46 +0100 Subject: [PATCH] svg size handling: Break out tokens as mut iterator We're going to restructure this to be a bit more like the structure in bundles. Signed-off-by: Ian Jackson --- src/utils.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 90a0903d..c0968f58 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -224,11 +224,14 @@ pub enum SVGSizeError { #[throws(SVGSizeError)] pub fn svg_parse_size(xml: &str) -> Option> { + let mut tokens = xmlparser::Tokenizer::from(xml) + .map(|t| t.map_err(|e| SvSE::ParseError(e.to_string()))); + use xmlparser::Token as Tk; let mut in_svg_element = false; let mut wh = [None; 2]; - for token in xmlparser::Tokenizer::from(xml) { - match token.map_err(|e| SvSE::ParseError(e.to_string()))? { + for token in &mut tokens { + match token? { Tk::ElementStart{ local, .. } => { in_svg_element = local.eq_ignore_ascii_case("svg"); }, -- 2.30.2