[librsvg: 4/10] Change the signature of the whitespace normalizer functions.
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 4/10] Change the signature of the whitespace normalizer functions.
- Date: Thu, 14 Dec 2017 03:26:23 +0000 (UTC)
commit 4a6be7c7a0ca3c6ac58757b2011374d3a1ad263d
Author: Jordan Petridis <jordanpetridis protonmail com>
Date: Fri Dec 8 08:14:55 2017 +0200
Change the signature of the whitespace normalizer functions.
Allow to pass any Type that can be converted into a CoW<str>.
rust/src/space.rs | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/rust/src/space.rs b/rust/src/space.rs
index 0dbc205..a82e3ae 100644
--- a/rust/src/space.rs
+++ b/rust/src/space.rs
@@ -1,6 +1,7 @@
use libc;
use glib::translate::*;
use itertools::Itertools;
+use std::borrow::Cow;
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
@@ -29,7 +30,8 @@ pub fn xml_space_normalize(mode: XmlSpace, s: &str) -> String {
// characters into space characters. Then, it will strip off all
// leading and trailing space characters. Then, all contiguous space
// characters will be consolidated.
-fn normalize_default(s: &str) -> String {
+fn normalize_default<'a, S: Into<Cow<'a, str>>>(s: S) -> String {
+ let s = s.into();
s.chars()
.filter(|ch| *ch != '\n')
.collect::<String>()
@@ -48,7 +50,8 @@ fn normalize_default(s: &str) -> String {
// xml:space="preserve", the string "a b" (three spaces between "a"
// and "b") will produce a larger separation between "a" and "b" than
// "a b" (one space between "a" and "b").
-fn normalize_preserve(s: &str) -> String {
+fn normalize_preserve<'a, S: Into<Cow<'a, str>>>(s: S) -> String {
+ let s = s.into();
let s = s.replace("\n", " ");
s.replace("\t", " ")
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]