[librsvg: 1/3] Fix needless late initialization
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/3] Fix needless late initialization
- Date: Mon, 21 Feb 2022 16:10:49 +0000 (UTC)
commit d47dc95264f4b66cb6c2d1c3ed456d9bfbd5f0f7
Author: Michael Howell <michael notriddle com>
Date: Mon Feb 14 14:54:23 2022 -0700
Fix needless late initialization
Recommended by nightly clippy.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/663>
src/accept_language.rs | 12 +++++-------
src/marker.rs | 22 ++++++++--------------
2 files changed, 13 insertions(+), 21 deletions(-)
---
diff --git a/src/accept_language.rs b/src/accept_language.rs
index 1a9819440..4034ed5eb 100644
--- a/src/accept_language.rs
+++ b/src/accept_language.rs
@@ -123,9 +123,7 @@ impl Item {
let tag = LanguageTag::parse(before_semicolon)
.map_err(AcceptLanguageError::InvalidLanguageTag)?;
- let weight;
-
- if let Some(quality) = after_semicolon {
+ let weight = if let Some(quality) = after_semicolon {
let quality = quality.trim_start_matches(&OWS[..]);
let number = if let Some(qvalue) = quality.strip_prefix("q=") {
@@ -154,12 +152,12 @@ impl Item {
return Err(AcceptLanguageError::InvalidWeight);
};
- weight = Weight(Some(
+ Weight(Some(
f32::from_str(number).map_err(|_| AcceptLanguageError::InvalidWeight)?,
- ));
+ ))
} else {
- weight = Weight(None);
- }
+ Weight(None)
+ };
Ok(Item { tag, weight })
}
diff --git a/src/marker.rs b/src/marker.rs
index 4fcf87e81..ee438201a 100644
--- a/src/marker.rs
+++ b/src/marker.rs
@@ -352,20 +352,14 @@ impl From<&Path> for Segments {
fn from(path: &Path) -> Segments {
let mut last_x: f64;
let mut last_y: f64;
- let mut cur_x: f64;
- let mut cur_y: f64;
- let mut subpath_start_x: f64;
- let mut subpath_start_y: f64;
- let mut segments: Vec<Segment>;
- let mut state: SegmentState;
-
- cur_x = 0.0;
- cur_y = 0.0;
- subpath_start_x = 0.0;
- subpath_start_y = 0.0;
-
- segments = Vec::new();
- state = SegmentState::Initial;
+
+ let mut cur_x: f64 = 0.0;
+ let mut cur_y: f64 = 0.0;
+ let mut subpath_start_x: f64 = 0.0;
+ let mut subpath_start_y: f64 = 0.0;
+
+ let mut segments = Vec::new();
+ let mut state = SegmentState::Initial;
for path_command in path.iter() {
last_x = cur_x;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]