xmpp-parsers: Use ToString::to_string as a map() argument

It’s more readable than using a closure for the same thing.
This commit is contained in:
Link Mauve 2025-11-22 22:20:06 +01:00
commit 4d1838d6cc

View file

@ -171,7 +171,7 @@ impl TryFrom<Element> for Body {
style: parse_css(elem.attr("style")), style: parse_css(elem.attr("style")),
xml_lang: elem xml_lang: elem
.attr_ns("xml", "lang") .attr_ns("xml", "lang")
.map(|xml_lang| xml_lang.to_string()), .map(ToString::to_string),
children, children,
}) })
} }
@ -325,9 +325,9 @@ impl TryFrom<Element> for Tag {
Ok(match elem.name() { Ok(match elem.name() {
"a" => Tag::A { "a" => Tag::A {
href: elem.attr("href").map(|href| href.to_string()), href: elem.attr("href").map(ToString::to_string),
style: parse_css(elem.attr(rxml::xml_ncname!("style"))), style: parse_css(elem.attr(rxml::xml_ncname!("style"))),
type_: elem.attr("type").map(|type_| type_.to_string()), type_: elem.attr("type").map(ToString::to_string),
children, children,
}, },
"blockquote" => Tag::Blockquote { "blockquote" => Tag::Blockquote {
@ -341,8 +341,8 @@ impl TryFrom<Element> for Tag {
}, },
"em" => Tag::Em { children }, "em" => Tag::Em { children },
"img" => Tag::Img { "img" => Tag::Img {
src: elem.attr("src").map(|src| src.to_string()), src: elem.attr("src").map(ToString::to_string),
alt: elem.attr("alt").map(|alt| alt.to_string()), alt: elem.attr("alt").map(ToString::to_string),
}, },
"li" => Tag::Li { "li" => Tag::Li {
style: parse_css(elem.attr("style")), style: parse_css(elem.attr("style")),
@ -505,7 +505,7 @@ fn parse_css(style: Option<&str>) -> Css {
for part in style.split(';') { for part in style.split(';') {
let mut part = part let mut part = part
.splitn(2, ':') .splitn(2, ':')
.map(|a| a.to_string()) .map(ToString::to_string)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let key = part.pop().unwrap(); let key = part.pop().unwrap();
let value = part.pop().unwrap(); let value = part.pop().unwrap();