[librsvg] impl Parse for RsvgLength



commit 0cd2fb2145c25898f296fe2c268f7527f58834c8
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Sep 4 21:18:04 2017 -0500

    impl Parse for RsvgLength

 rust/src/gradient.rs  |    1 +
 rust/src/length.rs    |   10 ++++++++--
 rust/src/structure.rs |    1 +
 3 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/rust/src/gradient.rs b/rust/src/gradient.rs
index 2010377..d5a7885 100644
--- a/rust/src/gradient.rs
+++ b/rust/src/gradient.rs
@@ -14,6 +14,7 @@ use handle::RsvgHandle;
 use length::*;
 use node::*;
 use paint_server::*;
+use parsers::Parse;
 use property_bag;
 use property_bag::*;
 use stop::*;
diff --git a/rust/src/length.rs b/rust/src/length.rs
index 4f5e00d..e208d37 100644
--- a/rust/src/length.rs
+++ b/rust/src/length.rs
@@ -6,6 +6,7 @@ use std::f64::consts::*;
 
 use drawing_ctx;
 use drawing_ctx::RsvgDrawingCtx;
+use parsers::Parse;
 use parsers::ParseError;
 use error::*;
 
@@ -100,8 +101,11 @@ fn make_err () -> AttributeError {
     AttributeError::Parse (ParseError::new ("expected length: number(\"em\" | \"ex\" | \"px\" | \"in\" | 
\"cm\" | \"mm\" | \"pt\" | \"pc\" | \"%\")?"))
 }
 
-impl RsvgLength {
-    pub fn parse (string: &str, dir: LengthDir) -> Result <RsvgLength, AttributeError> {
+impl Parse for RsvgLength {
+    type Data = LengthDir;
+    type Err = AttributeError;
+
+    fn parse (string: &str, dir: LengthDir) -> Result <RsvgLength, AttributeError> {
         let mut input = ParserInput::new (string);
         let mut parser = Parser::new (&mut input);
 
@@ -189,7 +193,9 @@ impl RsvgLength {
 
         Ok (length)
     }
+}
 
+impl RsvgLength {
     pub fn check_nonnegative (&self) -> Result <RsvgLength, AttributeError> {
         if self.length >= 0.0 {
             Ok (*self)
diff --git a/rust/src/structure.rs b/rust/src/structure.rs
index e660b19..19c5b19 100644
--- a/rust/src/structure.rs
+++ b/rust/src/structure.rs
@@ -14,6 +14,7 @@ use error::*;
 use handle::RsvgHandle;
 use length::*;
 use node::*;
+use parsers::Parse;
 use property_bag;
 use property_bag::*;
 use util::*;


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