[librsvg] error.rs: Fix is_parse_error() and is_value_error()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] error.rs: Fix is_parse_error() and is_value_error()
- Date: Thu, 16 Mar 2017 05:16:35 +0000 (UTC)
commit d5391b91c42ff823c9d669d8f03106eb12e3f674
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Mar 15 20:59:10 2017 -0600
error.rs: Fix is_parse_error() and is_value_error()
rust/src/error.rs | 24 ++++++++----------------
1 files changed, 8 insertions(+), 16 deletions(-)
---
diff --git a/rust/src/error.rs b/rust/src/error.rs
index 101f2b7..4df39d7 100644
--- a/rust/src/error.rs
+++ b/rust/src/error.rs
@@ -3,7 +3,7 @@ use std::error;
use parsers::ParseError;
-#[derive(Debug)]
+#[derive(Debug, Clone, PartialEq)]
pub enum AttributeError {
// parse error
Parse (ParseError),
@@ -12,7 +12,7 @@ pub enum AttributeError {
Value (String)
}
-#[derive(Debug)]
+#[derive(Debug, Clone, PartialEq)]
pub struct NodeError {
attr_name: &'static str,
err: AttributeError
@@ -66,23 +66,15 @@ impl From<ParseError> for AttributeError {
}
pub fn is_parse_error<T> (r: &Result<T, AttributeError>) -> bool {
- if r.is_err () {
- match r.unwrap_err () {
- AttributeError::Parse (_) => true,
- _ => false
- }
- } else {
- false
+ match *r {
+ Err (AttributeError::Parse (_)) => true,
+ _ => false
}
}
pub fn is_value_error<T> (r: &Result<T, AttributeError>) -> bool {
- if r.is_err () {
- match r.unwrap_err () {
- AttributeError::Value (_) => true,
- _ => false
- }
- } else {
- false
+ match *r {
+ Err (AttributeError::Value (_)) => true,
+ _ => false
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]