[librsvg] xml: use conditional match to shorten code
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] xml: use conditional match to shorten code
- Date: Sat, 18 May 2019 16:54:07 +0000 (UTC)
commit 52dd5ee4718505fb74e4c739f41746147fc7d16e
Author: Paolo Borelli <pborelli gnome org>
Date: Sat May 18 11:41:04 2019 +0200
xml: use conditional match to shorten code
rsvg_internals/src/xml.rs | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
---
diff --git a/rsvg_internals/src/xml.rs b/rsvg_internals/src/xml.rs
index 4eb66da1..ff553eea 100644
--- a/rsvg_internals/src/xml.rs
+++ b/rsvg_internals/src/xml.rs
@@ -113,22 +113,18 @@ impl XmlState {
pub fn steal_result(&mut self) -> Result<Svg, LoadingError> {
match self.tree_root {
None => Err(LoadingError::SvgHasNoElements),
+ Some(ref root) if root.get_type() == NodeType::Svg => {
+ let root = self.tree_root.take().unwrap();
- Some(ref root) => {
- if root.get_type() == NodeType::Svg {
- let root = self.tree_root.take().unwrap();
+ root.set_styles_recursively(&root, self.css_rules.as_ref().unwrap());
- root.set_styles_recursively(&root, self.css_rules.as_ref().unwrap());
-
- Ok(Svg::new(
- root,
- self.ids.take().unwrap(),
- self.load_options.clone(),
- ))
- } else {
- Err(LoadingError::RootElementIsNotSvg)
- }
+ Ok(Svg::new(
+ root,
+ self.ids.take().unwrap(),
+ self.load_options.clone(),
+ ))
}
+ _ => Err(LoadingError::RootElementIsNotSvg),
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]