[librsvg: 7/13] Rename IRI -> Iri per clippy




commit a87530c40d5d52e4a21f2a22186d149933beb856
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Apr 12 10:33:06 2021 -0500

    Rename IRI -> Iri per clippy

 src/iri.rs           | 46 +++++++++++++++++++++++-----------------------
 src/marker.rs        |  6 +++---
 src/properties.rs    |  8 ++++----
 src/property_defs.rs | 26 +++++++++++++-------------
 4 files changed, 43 insertions(+), 43 deletions(-)
---
diff --git a/src/iri.rs b/src/iri.rs
index 1a984c46..0aecc59e 100644
--- a/src/iri.rs
+++ b/src/iri.rs
@@ -13,41 +13,41 @@ use crate::parsers::Parse;
 /// does not take a funciri value (which looks like `url(...)`), but rather
 /// it takes a plain URL.
 #[derive(Debug, Clone, PartialEq)]
-pub enum IRI {
+pub enum Iri {
     None,
     Resource(Box<NodeId>),
 }
 
-impl Default for IRI {
-    fn default() -> IRI {
-        IRI::None
+impl Default for Iri {
+    fn default() -> Iri {
+        Iri::None
     }
 }
 
-impl IRI {
+impl Iri {
     /// Returns the contents of an `IRI::Resource`, or `None`
     pub fn get(&self) -> Option<&NodeId> {
         match *self {
-            IRI::None => None,
-            IRI::Resource(ref f) => Some(&*f),
+            Iri::None => None,
+            Iri::Resource(ref f) => Some(&*f),
         }
     }
 }
 
-impl Parse for IRI {
-    fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<IRI, ParseError<'i>> {
+impl Parse for Iri {
+    fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<Iri, ParseError<'i>> {
         if parser
             .try_parse(|i| i.expect_ident_matching("none"))
             .is_ok()
         {
-            Ok(IRI::None)
+            Ok(Iri::None)
         } else {
             let loc = parser.current_source_location();
             let url = parser.expect_url()?;
             let node_id =
                 NodeId::parse(&url).map_err(|e| loc.new_custom_error(ValueErrorKind::from(e)))?;
 
-            Ok(IRI::Resource(Box::new(node_id)))
+            Ok(Iri::Resource(Box::new(node_id)))
         }
     }
 }
@@ -58,19 +58,19 @@ mod tests {
 
     #[test]
     fn parses_none() {
-        assert_eq!(IRI::parse_str("none").unwrap(), IRI::None);
+        assert_eq!(Iri::parse_str("none").unwrap(), Iri::None);
     }
 
     #[test]
     fn parses_url() {
         assert_eq!(
-            IRI::parse_str("url(#bar)").unwrap(),
-            IRI::Resource(Box::new(NodeId::Internal("bar".to_string())))
+            Iri::parse_str("url(#bar)").unwrap(),
+            Iri::Resource(Box::new(NodeId::Internal("bar".to_string())))
         );
 
         assert_eq!(
-            IRI::parse_str("url(foo#bar)").unwrap(),
-            IRI::Resource(Box::new(NodeId::External(
+            Iri::parse_str("url(foo#bar)").unwrap(),
+            Iri::Resource(Box::new(NodeId::External(
                 "foo".to_string(),
                 "bar".to_string()
             )))
@@ -78,19 +78,19 @@ mod tests {
 
         // be permissive if the closing ) is missing
         assert_eq!(
-            IRI::parse_str("url(#bar").unwrap(),
-            IRI::Resource(Box::new(NodeId::Internal("bar".to_string())))
+            Iri::parse_str("url(#bar").unwrap(),
+            Iri::Resource(Box::new(NodeId::Internal("bar".to_string())))
         );
         assert_eq!(
-            IRI::parse_str("url(foo#bar").unwrap(),
-            IRI::Resource(Box::new(NodeId::External(
+            Iri::parse_str("url(foo#bar").unwrap(),
+            Iri::Resource(Box::new(NodeId::External(
                 "foo".to_string(),
                 "bar".to_string()
             )))
         );
 
-        assert!(IRI::parse_str("").is_err());
-        assert!(IRI::parse_str("foo").is_err());
-        assert!(IRI::parse_str("url(foo)bar").is_err());
+        assert!(Iri::parse_str("").is_err());
+        assert!(Iri::parse_str("foo").is_err());
+        assert!(Iri::parse_str("url(foo)bar").is_err());
     }
 }
diff --git a/src/marker.rs b/src/marker.rs
index 4fe662af..61383ccc 100644
--- a/src/marker.rs
+++ b/src/marker.rs
@@ -14,7 +14,7 @@ use crate::drawing_ctx::DrawingCtx;
 use crate::element::{Draw, Element, ElementResult, SetAttributes};
 use crate::error::*;
 use crate::float_eq_cairo::ApproxEqCairo;
-use crate::iri::IRI;
+use crate::iri::Iri;
 use crate::length::*;
 use crate::node::{CascadedValues, Node, NodeBorrow, NodeDraw};
 use crate::parsers::{Parse, ParseValue};
@@ -622,7 +622,7 @@ pub fn render_markers_for_path(
     let marker_mid = values.marker_mid().0;
     let marker_end = values.marker_end().0;
 
-    if let (&IRI::None, &IRI::None, &IRI::None) = (&marker_start, &marker_mid, &marker_end) {
+    if let (&Iri::None, &Iri::None, &Iri::None) = (&marker_start, &marker_mid, &marker_end) {
         return Ok(draw_ctx.empty_bbox());
     }
 
@@ -630,7 +630,7 @@ pub fn render_markers_for_path(
         path,
         draw_ctx.empty_bbox(),
         &mut |marker_type: MarkerType, x: f64, y: f64, computed_angle: Angle| {
-            if let IRI::Resource(ref marker) = match marker_type {
+            if let Iri::Resource(ref marker) = match marker_type {
                 MarkerType::Start => &marker_start,
                 MarkerType::Middle => &marker_mid,
                 MarkerType::End => &marker_end,
diff --git a/src/properties.rs b/src/properties.rs
index 67fb2790..abae1601 100644
--- a/src/properties.rs
+++ b/src/properties.rs
@@ -813,7 +813,7 @@ where
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::iri::IRI;
+    use crate::iri::Iri;
     use crate::length::*;
 
     #[test]
@@ -865,7 +865,7 @@ mod tests {
     #[test]
     fn expands_marker_shorthand() {
         let mut specified = SpecifiedValues::default();
-        let iri = IRI::parse_str("url(#foo)").unwrap();
+        let iri = Iri::parse_str("url(#foo)").unwrap();
 
         let marker = Marker(iri.clone());
         specified.set_parsed_property(&ParsedProperty::Marker(SpecifiedValue::Specified(marker)));
@@ -881,8 +881,8 @@ mod tests {
     #[test]
     fn replaces_marker_shorthand() {
         let mut specified = SpecifiedValues::default();
-        let iri1 = IRI::parse_str("url(#foo)").unwrap();
-        let iri2 = IRI::None;
+        let iri1 = Iri::parse_str("url(#foo)").unwrap();
+        let iri2 = Iri::None;
 
         let marker1 = Marker(iri1.clone());
         specified.set_parsed_property(&ParsedProperty::Marker(SpecifiedValue::Specified(marker1)));
diff --git a/src/property_defs.rs b/src/property_defs.rs
index a914e11a..567e25d4 100644
--- a/src/property_defs.rs
+++ b/src/property_defs.rs
@@ -49,7 +49,7 @@ use crate::dasharray::Dasharray;
 use crate::error::*;
 use crate::filter::FilterValueList;
 use crate::font_props::{Font, FontFamily, FontSize, FontWeight, LetterSpacing, LineHeight};
-use crate::iri::IRI;
+use crate::iri::Iri;
 use crate::length::*;
 use crate::paint_server::PaintServer;
 use crate::parsers::Parse;
@@ -122,9 +122,9 @@ make_property!(
 make_property!(
     ComputedValues,
     ClipPath,
-    default: IRI::None,
+    default: Iri::None,
     inherits_automatically: false,
-    newtype_parse: IRI,
+    newtype_parse: Iri,
 );
 
 // https://www.w3.org/TR/SVG/masking.html#ClipRuleProperty
@@ -484,45 +484,45 @@ make_property!(
 make_property!(
     ComputedValues,
     Marker,
-    default: IRI::None,
+    default: Iri::None,
     inherits_automatically: true,
-    newtype_parse: IRI,
+    newtype_parse: Iri,
 );
 
 // https://www.w3.org/TR/SVG/painting.html#MarkerEndProperty
 make_property!(
     ComputedValues,
     MarkerEnd,
-    default: IRI::None,
+    default: Iri::None,
     inherits_automatically: true,
-    newtype_parse: IRI,
+    newtype_parse: Iri,
 );
 
 // https://www.w3.org/TR/SVG/painting.html#MarkerMidProperty
 make_property!(
     ComputedValues,
     MarkerMid,
-    default: IRI::None,
+    default: Iri::None,
     inherits_automatically: true,
-    newtype_parse: IRI,
+    newtype_parse: Iri,
 );
 
 // https://www.w3.org/TR/SVG/painting.html#MarkerStartProperty
 make_property!(
     ComputedValues,
     MarkerStart,
-    default: IRI::None,
+    default: Iri::None,
     inherits_automatically: true,
-    newtype_parse: IRI,
+    newtype_parse: Iri,
 );
 
 // https://www.w3.org/TR/SVG/masking.html#MaskProperty
 make_property!(
     ComputedValues,
     Mask,
-    default: IRI::None,
+    default: Iri::None,
     inherits_automatically: false,
-    newtype_parse: IRI,
+    newtype_parse: Iri,
 );
 
 // https://www.w3.org/TR/compositing/#mix-blend-mode


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]