[librsvg] Adjust for rust-cssparser API changes
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Adjust for rust-cssparser API changes
- Date: Mon, 31 Jul 2017 18:09:09 +0000 (UTC)
commit df0ecd978cc21c1dd3cc03eecde7efd9fc066542
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Jul 31 12:51:50 2017 -0500
Adjust for rust-cssparser API changes
rust/src/length.rs | 20 +++++++++++---------
rust/src/opacity.rs | 4 ++--
rust/src/parsers.rs | 6 +++---
3 files changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/rust/src/length.rs b/rust/src/length.rs
index 62d49c8..d40cd72 100644
--- a/rust/src/length.rs
+++ b/rust/src/length.rs
@@ -108,16 +108,16 @@ impl RsvgLength {
let token = parser.next ()
.map_err (|_| AttributeError::Parse (ParseError::new ("expected number and optional symbol, or
number and percentage")))?;
- match *token {
- Token::Number { value, .. } => Ok (RsvgLength { length: value as f64,
+ match token {
+ &Token::Number { value, .. } => Ok (RsvgLength { length: value as f64,
unit: LengthUnit::Default,
dir: dir }),
- Token::Percentage { unit_value, .. } => Ok (RsvgLength { length: unit_value as f64,
+ &Token::Percentage { unit_value, .. } => Ok (RsvgLength { length: unit_value as f64,
unit:
LengthUnit::Percent,
dir: dir }),
- Token::Dimension { value, unit, .. } => {
+ &Token::Dimension { value, ref unit, .. } => {
let value = value as f64;
match unit.as_ref () {
@@ -153,12 +153,12 @@ impl RsvgLength {
unit: LengthUnit::Default,
dir: dir }),
- _ => Err (make_err ())
+ _ => return Err (make_err ());
}
},
// FIXME: why are the following in Length? They should be in FontSize
- Token::Ident (cow) => match cow.as_ref () {
+ &Token::Ident (ref cow) => match cow.as_ref () {
"larger" => Ok (RsvgLength { length: 0.0,
unit: LengthUnit::RelativeLarger,
dir: dir }),
@@ -177,11 +177,13 @@ impl RsvgLength {
unit: LengthUnit::Inch,
dir: dir }),
- _ => Err (make_err ())
+ _ => return Err (make_err ());
},
- _ => Err (make_err ())
- }.and_then (|r|
+ _ => return Err (make_err ());
+ };
+
+ .and_then (|r|
parser.expect_exhausted ()
.map (|_| r)
.map_err (|_| make_err ()))
diff --git a/rust/src/opacity.rs b/rust/src/opacity.rs
index cd9ca8a..5d9e26d 100644
--- a/rust/src/opacity.rs
+++ b/rust/src/opacity.rs
@@ -72,8 +72,8 @@ impl FromStr for Opacity {
let token = parser.next ();
let result = match token {
- Ok (&Token::Ident (value)) => {
- if value == "inherit" {
+ Ok (&Token::Ident (ref value)) => {
+ if value.as_ref () == "inherit" {
Ok (Opacity::Inherit)
} else {
Err (())
diff --git a/rust/src/parsers.rs b/rust/src/parsers.rs
index a4e38f6..56ba7a3 100644
--- a/rust/src/parsers.rs
+++ b/rust/src/parsers.rs
@@ -40,10 +40,10 @@ pub fn angle_degrees (s: &str) -> Result <f64, ParseError> {
let token = parser.next ()
.map_err (|_| ParseError::new ("expected angle"))?;
- match *token {
- Token::Number { value, .. } => Ok (value as f64),
+ match token {
+ &Token::Number { value, .. } => Ok (value as f64),
- Token::Dimension { value, unit, .. } => {
+ &Token::Dimension { value, ref unit, .. } => {
let value = value as f64;
match unit.as_ref () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]