[librsvg: 10/19] Make the early return explicit instead of using Err(x)?
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 10/19] Make the early return explicit instead of using Err(x)?
- Date: Fri, 21 Aug 2020 18:30:17 +0000 (UTC)
commit bdc2b6a1366e10b37ea24dbbc112ceeeb2283d3b
Author: Sven Neumann <sven svenfoo org>
Date: Fri Aug 21 00:06:05 2020 +0200
Make the early return explicit instead of using Err(x)?
See https://rust-lang.github.io/rust-clippy/master/index.html#try_err
rsvg_internals/src/font_props.rs | 6 ++++--
rsvg_internals/src/parsers.rs | 4 ++--
rsvg_internals/src/property_defs.rs | 2 +-
3 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/rsvg_internals/src/font_props.rs b/rsvg_internals/src/font_props.rs
index 6cae0bf92..beb7daa4b 100644
--- a/rsvg_internals/src/font_props.rs
+++ b/rsvg_internals/src/font_props.rs
@@ -435,7 +435,9 @@ impl Parse for LineHeight {
if cow.eq_ignore_ascii_case("normal") {
Ok(LineHeight::Normal)
} else {
- Err(parser.new_basic_unexpected_token_error(token.clone()))?
+ Err(parser
+ .new_basic_unexpected_token_error(token.clone())
+ .into())
}
}
@@ -450,7 +452,7 @@ impl Parse for LineHeight {
Ok(LineHeight::Length(Length::<Both>::parse(parser)?))
}
- _ => Err(parser.new_basic_unexpected_token_error(token))?,
+ _ => Err(parser.new_basic_unexpected_token_error(token).into()),
}
}
}
diff --git a/rsvg_internals/src/parsers.rs b/rsvg_internals/src/parsers.rs
index db0b1107a..80b6f8cf8 100644
--- a/rsvg_internals/src/parsers.rs
+++ b/rsvg_internals/src/parsers.rs
@@ -161,14 +161,14 @@ impl Parse for CustomIdent {
Token::Ident(ref cow) => {
for s in &["initial", "inherit", "unset", "default"] {
if cow.eq_ignore_ascii_case(s) {
- Err(loc.new_basic_unexpected_token_error(token.clone()))?
+ return Err(loc.new_basic_unexpected_token_error(token.clone()).into());
}
}
Ok(CustomIdent(cow.as_ref().to_string()))
}
- _ => Err(loc.new_basic_unexpected_token_error(token.clone()))?,
+ _ => Err(loc.new_basic_unexpected_token_error(token.clone()).into()),
}
}
}
diff --git a/rsvg_internals/src/property_defs.rs b/rsvg_internals/src/property_defs.rs
index 1dda3063b..b97993c84 100644
--- a/rsvg_internals/src/property_defs.rs
+++ b/rsvg_internals/src/property_defs.rs
@@ -586,7 +586,7 @@ make_property!(
Token::Ident(ref cow) if cow.eq_ignore_ascii_case("overline") => overline = true,
Token::Ident(ref cow) if cow.eq_ignore_ascii_case("underline") => underline = true,
Token::Ident(ref cow) if cow.eq_ignore_ascii_case("line-through") => strike = true,
- _ => Err(loc.new_basic_unexpected_token_error(token.clone()))?,
+ _ => return Err(loc.new_basic_unexpected_token_error(token.clone()).into()),
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]