[librsvg/rustify-rsvg-convert: 2/9] rsvg-convert: cleanup resize strategy




commit 3fe493221fe833203073c801c0f382fad87cb83d
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Jan 16 18:46:45 2021 +0100

    rsvg-convert: cleanup resize strategy

 src/bin/rsvg-convert/main.rs | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/bin/rsvg-convert/main.rs b/src/bin/rsvg-convert/main.rs
index f694a963..98cd8aeb 100644
--- a/src/bin/rsvg-convert/main.rs
+++ b/src/bin/rsvg-convert/main.rs
@@ -47,9 +47,9 @@ enum ResizeStrategy {
 }
 
 impl ResizeStrategy {
-    pub fn apply(self, input: Size, keep_aspect_ratio: bool) -> Result<Size, ()> {
+    pub fn apply(self, input: Size, keep_aspect_ratio: bool) -> Option<Size> {
         if input.w == 0.0 || input.h == 0.0 {
-            return Err(());
+            return None;
         }
 
         let output = match self {
@@ -96,14 +96,14 @@ impl ResizeStrategy {
         };
 
         if !keep_aspect_ratio {
-            Ok(output)
+            Some(output)
         } else if output.w < output.h {
-            Ok(Size {
+            Some(Size {
                 w: output.w,
                 h: input.h * (output.w / input.w),
             })
         } else {
-            Ok(Size {
+            Some(Size {
                 w: input.w * (output.h / input.h),
                 h: output.h,
             })
@@ -427,7 +427,7 @@ impl Converter {
 
         let size = strategy
             .apply(Size::new(width, height), self.keep_aspect_ratio)
-            .unwrap_or_else(|_| exit!("The SVG {} has no dimensions", input));
+            .unwrap_or_else(|| exit!("The SVG {} has no dimensions", input));
 
         let output_stream = match self.output {
             Output::Stdout => Stdout::stream().upcast::<OutputStream>(),


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