[librsvg/rustify-rsvg-convert: 51/78] rsvg-convert: cleanup resize strategy




commit 2beaf8c7442056e5978d506c5814b9248ed31bed
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 5f29c4af..4d986e64 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,
             })
@@ -425,7 +425,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]