[librsvg] space::normalize_preserve() - Use iterator functions instead of making fire by rubbing sticks



commit 6ecccdfe2beaece2890acaf0461856001115b6d4
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Dec 7 09:24:47 2017 -0600

    space::normalize_preserve() - Use iterator functions instead of making fire by rubbing sticks

 rust/src/space.rs |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/rust/src/space.rs b/rust/src/space.rs
index 8f364ed..48531c0 100644
--- a/rust/src/space.rs
+++ b/rust/src/space.rs
@@ -53,17 +53,15 @@ fn normalize_default(s: &str) -> String {
 }
 
 fn normalize_preserve(s: &str) -> String {
-    let mut result = String::new();
+    s.chars()
+        .map(|ch| {
+            match ch {
+                '\n' | '\t' => ' ',
 
-    for ch in s.chars() {
-        match ch {
-            '\n' | '\t' => result.push(' '),
-
-            _ => result.push(ch),
-        }
-    }
-
-    result
+                c => c
+            }
+        })
+        .collect()
 }
 
 #[cfg(test)]


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