aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2014-04-03 11:08:17 -0400
committerBruno de Oliveira Abinader <bruno.d@partner.samsung.com>2014-04-04 09:08:36 -0400
commit594df4d696be81debe30c4b95a4db3fde17213e1 (patch)
tree58f80c286d4b2eeb45f96750558e611d0d8780d1 /src
parentfe1615bc3dc3bd2f8d3fbb6f776e701b4c6dda76 (diff)
downloadservo-594df4d696be81debe30c4b95a4db3fde17213e1.tar.gz
servo-594df4d696be81debe30c4b95a4db3fde17213e1.zip
Implement split_html_space_chars helper function
Diffstat (limited to 'src')
-rw-r--r--src/components/util/str.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/components/util/str.rs b/src/components/util/str.rs
index cdbf1bb9ea9..abd5984b8ef 100644
--- a/src/components/util/str.rs
+++ b/src/components/util/str.rs
@@ -2,7 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use std::iter::Filter;
+use std::str::CharSplits;
+
pub type DOMString = ~str;
+pub type StaticCharVec = &'static [char];
pub type StaticStringVec = &'static [&'static str];
pub fn null_str_as_empty(s: &Option<DOMString>) -> DOMString {
@@ -31,7 +35,7 @@ pub fn is_whitespace(s: &str) -> bool {
///
/// http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#
/// space-character
-pub static HTML_SPACE_CHARACTERS: [char, ..5] = [
+pub static HTML_SPACE_CHARACTERS: StaticCharVec = &[
'\u0020',
'\u0009',
'\u000a',
@@ -39,3 +43,6 @@ pub static HTML_SPACE_CHARACTERS: [char, ..5] = [
'\u000d',
];
+pub fn split_html_space_chars<'a>(s: &'a str) -> Filter<'a, &'a str, CharSplits<'a, StaticCharVec>> {
+ s.split(HTML_SPACE_CHARACTERS).filter(|&split| !split.is_empty())
+}