[librsvg: 5/12] Clear needless_return, let_and_return and or_fun_call warnings.



commit cb005237f9bc6c8122564bc0befa7cb97a363870
Author: Jordan Petridis <jordanpetridis protonmail com>
Date:   Sun Dec 17 09:47:03 2017 +0200

    Clear needless_return, let_and_return and or_fun_call warnings.
    
    For more see:
    https://rust-lang-nursery.github.io/rust-clippy/v0.0.176/index.html#needless_return
    https://rust-lang-nursery.github.io/rust-clippy/v0.0.176/index.html#let_and_return
    https://rust-lang-nursery.github.io/rust-clippy/v0.0.176/index.html#or_fun_call

 rust/src/drawing_ctx.rs  |  4 +---
 rust/src/gradient.rs     |  2 +-
 rust/src/length.rs       |  4 ++--
 rust/src/path_builder.rs |  6 ++----
 rust/src/path_parser.rs  | 18 +++++++++---------
 rust/src/pattern.rs      |  3 +--
 rust/src/structure.rs    |  4 ++--
 7 files changed, 18 insertions(+), 23 deletions(-)
---
diff --git a/rust/src/drawing_ctx.rs b/rust/src/drawing_ctx.rs
index 77e0257..f6889e0 100644
--- a/rust/src/drawing_ctx.rs
+++ b/rust/src/drawing_ctx.rs
@@ -178,9 +178,7 @@ pub fn get_cairo_context (draw_ctx: *const RsvgDrawingCtx) -> cairo::Context {
     unsafe {
         let raw_cr = rsvg_cairo_get_cairo_context (draw_ctx);
 
-        let cr = cairo::Context::from_glib_none (raw_cr);
-
-        cr
+        cairo::Context::from_glib_none (raw_cr)
     }
 }
 
diff --git a/rust/src/gradient.rs b/rust/src/gradient.rs
index 1c09baf..82625e5 100644
--- a/rust/src/gradient.rs
+++ b/rust/src/gradient.rs
@@ -349,7 +349,7 @@ impl FallbackSource for NodeFallbackSource {
 
         self.acquired_nodes.push (fallback_node);
 
-        return Some (node.clone ());
+        Some (node.clone ())
     }
 }
 
diff --git a/rust/src/length.rs b/rust/src/length.rs
index aee3772..54cf65b 100644
--- a/rust/src/length.rs
+++ b/rust/src/length.rs
@@ -82,7 +82,7 @@ pub extern fn rsvg_length_parse (string: *const libc::c_char, dir: LengthDir) ->
     let my_string = unsafe { &String::from_glib_none (string) };
 
     // FIXME: this ignores errors; propagate them upstream
-    RsvgLength::parse (my_string, dir).unwrap_or (RsvgLength::default ())
+    RsvgLength::parse (my_string, dir).unwrap_or_else(|_| {RsvgLength::default ()})
 }
 
 /* https://www.w3.org/TR/SVG/types.html#DataTypeLength
@@ -286,7 +286,7 @@ fn viewport_percentage (x: f64, y: f64) -> f64 {
      * percentage is calculated as the specified percentage of
      * sqrt((actual-width)**2 + (actual-height)**2))/sqrt(2)."
      */
-    return (x * x + y * y).sqrt () / SQRT_2;
+    (x * x + y * y).sqrt () / SQRT_2
 }
 
 #[no_mangle]
diff --git a/rust/src/path_builder.rs b/rust/src/path_builder.rs
index f1434c5..3911a7d 100644
--- a/rust/src/path_builder.rs
+++ b/rust/src/path_builder.rs
@@ -27,11 +27,9 @@ pub struct RsvgPathBuilder {
 
 impl RsvgPathBuilder {
     pub fn new () -> RsvgPathBuilder {
-        let builder = RsvgPathBuilder {
+        RsvgPathBuilder {
             path_commands: Vec::new ()
-        };
-
-        builder
+        }
     }
 
     pub fn move_to (&mut self, x: f64, y: f64) {
diff --git a/rust/src/path_parser.rs b/rust/src/path_parser.rs
index 72b7f1f..f8eaffd 100644
--- a/rust/src/path_parser.rs
+++ b/rust/src/path_parser.rs
@@ -90,9 +90,9 @@ impl<'b> PathParser<'b> {
     fn parse (&mut self) -> bool {
         self.getchar ();
 
-        return self.optional_whitespace () &&
+        self.optional_whitespace () &&
             self.moveto_drawto_command_groups () &&
-            self.optional_whitespace ();
+            self.optional_whitespace ()
     }
 
     fn getchar (&mut self) {
@@ -272,11 +272,11 @@ impl<'b> PathParser<'b> {
 
     fn flag (&mut self) -> Option <bool> {
         if self.match_char ('0') {
-            return Some (false);
+            Some (false)
         } else if self.match_char ('1') {
-            return Some (true);
+            Some (true)
         } else {
-            return None;
+            None
         }
     }
 
@@ -464,8 +464,8 @@ impl<'b> PathParser<'b> {
 
     fn moveto_drawto_command_group (&mut self, is_initial_moveto: bool) -> bool {
         if self.moveto (is_initial_moveto) {
-            return self.optional_whitespace () &&
-                self.optional_drawto_commands ();
+            self.optional_whitespace () &&
+                self.optional_drawto_commands ()
         } else {
             false
         }
@@ -500,7 +500,7 @@ impl<'b> PathParser<'b> {
     }
 
     fn drawto_command (&mut self) -> bool {
-        return self.close_path () ||
+        self.close_path () ||
             self.line_to () ||
             self.horizontal_line_to () ||
             self.vertical_line_to () ||
@@ -508,7 +508,7 @@ impl<'b> PathParser<'b> {
             self.smooth_curve_to () ||
             self.quadratic_bezier_curve_to () ||
             self.smooth_quadratic_bezier_curve_to () ||
-            self.elliptical_arc ();
+            self.elliptical_arc ()
     }
 
     fn close_path (&mut self) -> bool {
diff --git a/rust/src/pattern.rs b/rust/src/pattern.rs
index 111f2a9..3153be1 100644
--- a/rust/src/pattern.rs
+++ b/rust/src/pattern.rs
@@ -70,8 +70,7 @@ fn node_has_children (node: &Option<Weak<Node>>) -> bool {
 
         Some (ref weak) => {
             let ref strong_node = weak.clone ().upgrade ().unwrap ();
-            let has_children = strong_node.children.borrow ().len () > 0;
-            has_children
+            return strong_node.children.borrow ().len () > 0;
         }
     }
 }
diff --git a/rust/src/structure.rs b/rust/src/structure.rs
index 62f7c7f..3329e7d 100644
--- a/rust/src/structure.rs
+++ b/rust/src/structure.rs
@@ -269,9 +269,9 @@ impl NodeTrait for NodeUse {
         // From https://www.w3.org/TR/SVG/struct.html#UseElement in
         // "If the ‘use’ element references a ‘symbol’ element"
         
-        let nw = self.w.get ().unwrap_or (RsvgLength::parse ("100%", LengthDir::Horizontal).unwrap ())
+        let nw = self.w.get ().unwrap_or_else(|| { RsvgLength::parse ("100%", LengthDir::Horizontal).unwrap 
()})
             .normalize (draw_ctx);
-        let nh = self.h.get ().unwrap_or (RsvgLength::parse ("100%", LengthDir::Vertical).unwrap ())
+        let nh = self.h.get ().unwrap_or_else(|| { RsvgLength::parse ("100%", LengthDir::Vertical).unwrap 
()})
             .normalize (draw_ctx);
 
         // width or height set to 0 disables rendering of the element


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