Avoid usage of bool::then_some()

This commit is contained in:
Dirkjan Ochtman 2023-02-27 10:28:47 +01:00
parent 8a958342d6
commit 8cbb29b388
1 changed files with 13 additions and 4 deletions

View File

@ -211,7 +211,10 @@ impl<'xml> Iterator for Context<'xml> {
let prefix = prefix.as_str(); let prefix = prefix.as_str();
current = Some(Level { current = Some(Level {
local: local.as_str(), local: local.as_str(),
prefix: (!prefix.is_empty()).then_some(prefix), prefix: match prefix.is_empty() {
true => None,
false => Some(prefix),
},
default_ns: None, default_ns: None,
prefixes: BTreeMap::new(), prefixes: BTreeMap::new(),
}); });
@ -247,7 +250,11 @@ impl<'xml> Iterator for Context<'xml> {
} }
}; };
let prefix = (!prefix.is_empty()).then_some(prefix.as_str()); let prefix = match prefix.is_empty() {
true => None,
false => Some(prefix.as_str()),
};
match v.as_str() == level.local && prefix == level.prefix { match v.as_str() == level.local && prefix == level.prefix {
true => { true => {
return Some(Ok(Node::Close { return Some(Ok(Node::Close {
@ -313,9 +320,11 @@ impl<'xml> Iterator for Context<'xml> {
} }
} }
} else { } else {
let prefix = (!prefix.is_empty()).then_some(prefix.as_str());
self.records.push_back(Node::Attribute(Attribute { self.records.push_back(Node::Attribute(Attribute {
prefix, prefix: match prefix.is_empty() {
true => None,
false => Some(prefix.as_str()),
},
local: local.as_str(), local: local.as_str(),
value: value.as_str(), value: value.as_str(),
})); }));