aboutsummaryrefslogtreecommitdiff
path: root/src/parser.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-03-09 11:09:07 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-03-09 11:09:07 -0700
commitff3bb7d25505a565f8bdfd73b1105ae15a1e6f4b (patch)
tree8a4ea1156fb932cc8dc72171c6d81450ea24d52f /src/parser.rs
parente14c2052b721d4f400f240e5711ed9510dd1b102 (diff)
downloadmilf-rs-ff3bb7d25505a565f8bdfd73b1105ae15a1e6f4b.tar.gz
milf-rs-ff3bb7d25505a565f8bdfd73b1105ae15a1e6f4b.zip
Reduce usage of unstable features
Diffstat (limited to 'src/parser.rs')
-rw-r--r--src/parser.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 7c991c4..abb4c5c 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -1,3 +1,4 @@
+use std::ascii::AsciiExt;
use std::char;
use std::collections::BTreeMap;
use std::error::Error;
@@ -385,8 +386,9 @@ impl<'a> Parser<'a> {
Some((pos, c @ 'u')) |
Some((pos, c @ 'U')) => {
let len = if c == 'u' {4} else {8};
- let num = if me.input.is_char_boundary(pos + 1 + len) {
- &me.input[pos + 1 .. pos + 1 + len]
+ let num = &me.input[pos+1..];
+ let num = if num.len() >= len && num.is_ascii() {
+ &num[..len]
} else {
"invalid"
};
@@ -614,7 +616,7 @@ impl<'a> Parser<'a> {
lo: start,
hi: next,
desc: format!("unexpected character: `{}`",
- rest.char_at(0)),
+ rest.chars().next().unwrap()),
});
None
}