Skip to content

Commit 8b8ae47

Browse files
author
Clar Charr
committed
Make split_whitespace use split_terminator.
1 parent 663b266 commit 8b8ae47

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

src/libcore/str/mod.rs

+2-21
Original file line numberDiff line numberDiff line change
@@ -2551,7 +2551,7 @@ impl StrExt for str {
25512551

25522552
#[inline]
25532553
fn split_whitespace(&self) -> SplitWhitespace {
2554-
SplitWhitespace { inner: self.split(IsWhitespace).filter(IsNotEmpty) }
2554+
SplitWhitespace { inner: self.split_terminator(IsWhitespace) }
25552555
}
25562556

25572557
#[inline]
@@ -2605,7 +2605,7 @@ impl<'a> Default for &'a str {
26052605
#[stable(feature = "split_whitespace", since = "1.1.0")]
26062606
#[derive(Clone, Debug)]
26072607
pub struct SplitWhitespace<'a> {
2608-
inner: Filter<Split<'a, IsWhitespace>, IsNotEmpty>,
2608+
inner: SplitTerminator<'a, IsWhitespace>>,
26092609
}
26102610

26112611
#[derive(Clone)]
@@ -2627,25 +2627,6 @@ impl FnMut<(char, )> for IsWhitespace {
26272627
}
26282628
}
26292629

2630-
#[derive(Clone)]
2631-
struct IsNotEmpty;
2632-
2633-
impl<'a, 'b> FnOnce<(&'a &'b str, )> for IsNotEmpty {
2634-
type Output = bool;
2635-
2636-
#[inline]
2637-
extern "rust-call" fn call_once(mut self, arg: (&&str, )) -> bool {
2638-
self.call_mut(arg)
2639-
}
2640-
}
2641-
2642-
impl<'a, 'b> FnMut<(&'a &'b str, )> for IsNotEmpty {
2643-
#[inline]
2644-
extern "rust-call" fn call_mut(&mut self, arg: (&&str, )) -> bool {
2645-
!arg.0.is_empty()
2646-
}
2647-
}
2648-
26492630

26502631
#[stable(feature = "split_whitespace", since = "1.1.0")]
26512632
impl<'a> Iterator for SplitWhitespace<'a> {

0 commit comments

Comments
 (0)