diff options
author | zakorgyula <gyula.zakor@gmail.com> | 2016-04-20 10:40:57 +0200 |
---|---|---|
committer | zakorgyula <gyula.zakor@gmail.com> | 2016-04-20 10:40:57 +0200 |
commit | 95bebb9945de2bd51e4d2aa3b49032c2dfcaa3ad (patch) | |
tree | 25dd7c326e918eae62cb1032d5eb2c2ef3d384ab /components/util/str.rs | |
parent | bebc1dc859192d7fdcfc53e550cbf51343f4375a (diff) | |
download | servo-95bebb9945de2bd51e4d2aa3b49032c2dfcaa3ad.tar.gz servo-95bebb9945de2bd51e4d2aa3b49032c2dfcaa3ad.zip |
Remove extra definition of WHITESPACE under components/util/str.rs
Diffstat (limited to 'components/util/str.rs')
-rw-r--r-- | components/util/str.rs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/components/util/str.rs b/components/util/str.rs index e7aa933cecf..b0a3d6c2c9e 100644 --- a/components/util/str.rs +++ b/components/util/str.rs @@ -124,19 +124,6 @@ impl Extend<char> for DOMString { pub type StaticCharVec = &'static [char]; pub type StaticStringVec = &'static [&'static str]; -/// Whitespace as defined by HTML5 § 2.4.1. -// TODO(SimonSapin) Maybe a custom Pattern can be more efficient? -pub const WHITESPACE: &'static [char] = &[' ', '\t', '\x0a', '\x0c', '\x0d']; - -pub fn is_whitespace(s: &str) -> bool { - s.chars().all(char_is_whitespace) -} - -#[inline] -pub fn char_is_whitespace(c: char) -> bool { - WHITESPACE.contains(&c) -} - /// A "space character" according to: /// /// https://html.spec.whatwg.org/multipage/#space-character @@ -148,6 +135,15 @@ pub static HTML_SPACE_CHARACTERS: StaticCharVec = &[ '\u{000d}', ]; +#[inline] +pub fn char_is_whitespace(c: char) -> bool { + HTML_SPACE_CHARACTERS.contains(&c) +} + +pub fn is_whitespace(s: &str) -> bool { + s.chars().all(char_is_whitespace) +} + pub fn split_html_space_chars<'a>(s: &'a str) -> Filter<Split<'a, StaticCharVec>, fn(&&str) -> bool> { fn not_empty(&split: &&str) -> bool { !split.is_empty() } |