Skip to content

Commit 36f45ca

Browse files
bors[bot]burrbull
andauthored
Merge #103
103: ignore empty optional tag when get text r=therealprof a=burrbull r? @therealprof This should fix faults on empty optional text tags like `<description/>`. Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2 parents 27beb89 + 0775c74 commit 36f45ca

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/elementext.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ impl ElementExt for Element {
3535
String: PartialEq<K>,
3636
{
3737
if let Some(child) = self.get_child(k) {
38-
Ok(Some(child.get_text().map(|s| s.to_owned())?))
38+
match child.get_text() {
39+
Err(e) => match e.downcast_ref() {
40+
// if tag is empty just ignore it
41+
Some(SVDError::EmptyTag(_, _)) => Ok(None),
42+
_ => return Err(e),
43+
},
44+
Ok(s) => Ok(Some(s.to_owned())),
45+
}
3946
} else {
4047
Ok(None)
4148
}

0 commit comments

Comments
 (0)