[librsvg: 3/4] Use Option::map_or() and Option::map_or_else()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 3/4] Use Option::map_or() and Option::map_or_else()
- Date: Fri, 16 Oct 2020 15:32:59 +0000 (UTC)
commit e3d9837867b401223079177e3eee9d74e3fba7ae
Author: Sven Neumann <sven svenfoo org>
Date: Thu Oct 15 20:54:26 2020 +0200
Use Option::map_or() and Option::map_or_else()
These are shorthands for the
.map(|val| process(val)).unwrap_or(default) pattern.
rsvg_internals/src/bbox.rs | 4 ++--
rsvg_internals/src/xml2_load.rs | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/rsvg_internals/src/bbox.rs b/rsvg_internals/src/bbox.rs
index 46dba3a0..d3f2d277 100644
--- a/rsvg_internals/src/bbox.rs
+++ b/rsvg_internals/src/bbox.rs
@@ -64,11 +64,11 @@ impl BoundingBox {
}
pub fn rect_is_empty(&self) -> bool {
- self.rect.map(|r| r.is_empty()).unwrap_or(true)
+ self.rect.map_or(true, |r| r.is_empty())
}
pub fn ink_rect_is_empty(&self) -> bool {
- self.ink_rect.map(|r| r.is_empty()).unwrap_or(true)
+ self.ink_rect.map_or(true, |r| r.is_empty())
}
/// Creates a transform to map to the `self.rect`.
diff --git a/rsvg_internals/src/xml2_load.rs b/rsvg_internals/src/xml2_load.rs
index 771b5e02..fe17fcec 100644
--- a/rsvg_internals/src/xml2_load.rs
+++ b/rsvg_internals/src/xml2_load.rs
@@ -183,7 +183,7 @@ fn make_qual_name(prefix: Option<&str>, uri: Option<&str>, localname: &str) -> Q
// FIXME: If the element doesn't have a namespace URI, we are falling back
// to the SVG namespace. In reality we need to take namespace scoping into account,
// i.e. handle the "default namespace" active at that point in the XML stack.
- let element_ns = uri.map(Namespace::from).unwrap_or_else(|| ns!(svg));
+ let element_ns = uri.map_or_else(|| ns!(svg), Namespace::from);
QualName::new(
prefix.map(Prefix::from),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]