Readability improvement in tag handling.

This commit is contained in:
Ethiraric 2024-04-02 23:00:33 +02:00
parent 6b01b554e0
commit 3365ccadb6

View file

@ -1037,16 +1037,13 @@ impl<T: Iterator<Item = char>> Parser<T> {
if handle == "!!" { if handle == "!!" {
// "!!" is a shorthand for "tag:yaml.org,2002:". However, that default can be // "!!" is a shorthand for "tag:yaml.org,2002:". However, that default can be
// overridden. // overridden.
match self.tags.get("!!") { Ok(Tag {
Some(prefix) => Ok(Tag { handle: self
handle: prefix.to_string(), .tags
.get("!!")
.map_or_else(|| "tag:yaml.org,2002:".to_string(), ToString::to_string),
suffix, suffix,
}), })
None => Ok(Tag {
handle: "tag:yaml.org,2002:".to_string(),
suffix,
}),
}
} else if handle.is_empty() && suffix == "!" { } else if handle.is_empty() && suffix == "!" {
// "!" introduces a local tag. Local tags may have their prefix overridden. // "!" introduces a local tag. Local tags may have their prefix overridden.
match self.tags.get("") { match self.tags.get("") {