This commit is contained in:
mcarton
2016-03-12 21:23:35 +01:00
parent eba41430ce
commit 04d81799a2

View File

@@ -383,14 +383,14 @@ fn trim_multiline_inner(s: Cow<str>, ignore_first: bool, ch: char) -> Cow<str> {
let x = s.lines() let x = s.lines()
.skip(ignore_first as usize) .skip(ignore_first as usize)
.filter_map(|l| { .filter_map(|l| {
if l.len() > 0 { if l.is_empty() {
None
} else {
// ignore empty lines // ignore empty lines
Some(l.char_indices() Some(l.char_indices()
.find(|&(_, x)| x != ch) .find(|&(_, x)| x != ch)
.unwrap_or((l.len(), ch)) .unwrap_or((l.len(), ch))
.0) .0)
} else {
None
} }
}) })
.min() .min()
@@ -399,7 +399,7 @@ fn trim_multiline_inner(s: Cow<str>, ignore_first: bool, ch: char) -> Cow<str> {
Cow::Owned(s.lines() Cow::Owned(s.lines()
.enumerate() .enumerate()
.map(|(i, l)| { .map(|(i, l)| {
if (ignore_first && i == 0) || l.len() == 0 { if (ignore_first && i == 0) || l.is_empty() {
l l
} else { } else {
l.split_at(x).1 l.split_at(x).1