aboutsummaryrefslogtreecommitdiff
path: root/src
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
parente14c2052b721d4f400f240e5711ed9510dd1b102 (diff)
downloadmilf-rs-ff3bb7d25505a565f8bdfd73b1105ae15a1e6f4b.tar.gz
milf-rs-ff3bb7d25505a565f8bdfd73b1105ae15a1e6f4b.zip
Reduce usage of unstable features
Diffstat (limited to 'src')
-rw-r--r--src/display.rs28
-rw-r--r--src/lib.rs8
-rw-r--r--src/parser.rs8
-rw-r--r--src/serialization.rs4
4 files changed, 26 insertions, 22 deletions
diff --git a/src/display.rs b/src/display.rs
index f1b2a76..0c561e8 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -138,36 +138,36 @@ mod tests {
#[test]
fn simple_show() {
- assert_eq!(String("foo".to_string()).to_string().as_slice(),
+ assert_eq!(String("foo".to_string()).to_string(),
"\"foo\"");
- assert_eq!(Integer(10).to_string().as_slice(),
+ assert_eq!(Integer(10).to_string(),
"10");
- assert_eq!(Float(10.0).to_string().as_slice(),
+ assert_eq!(Float(10.0).to_string(),
"10.0");
- assert_eq!(Float(2.4).to_string().as_slice(),
+ assert_eq!(Float(2.4).to_string(),
"2.4");
- assert_eq!(Boolean(true).to_string().as_slice(),
+ assert_eq!(Boolean(true).to_string(),
"true");
- assert_eq!(Datetime("test".to_string()).to_string().as_slice(),
+ assert_eq!(Datetime("test".to_string()).to_string(),
"test");
- assert_eq!(Array(vec![]).to_string().as_slice(),
+ assert_eq!(Array(vec![]).to_string(),
"[]");
- assert_eq!(Array(vec![Integer(1), Integer(2)]).to_string().as_slice(),
+ assert_eq!(Array(vec![Integer(1), Integer(2)]).to_string(),
"[1, 2]");
}
#[test]
fn table() {
- assert_eq!(Table(map! { }).to_string().as_slice(),
+ assert_eq!(Table(map! { }).to_string(),
"");
- assert_eq!(Table(map! { "test" => Integer(2) }).to_string().as_slice(),
+ assert_eq!(Table(map! { "test" => Integer(2) }).to_string(),
"test = 2\n");
assert_eq!(Table(map! {
"test" => Integer(2),
"test2" => Table(map! {
"test" => String("wut".to_string())
})
- }).to_string().as_slice(),
+ }).to_string(),
"test = 2\n\
\n\
[test2]\n\
@@ -177,7 +177,7 @@ mod tests {
"test2" => Table(map! {
"test" => String("wut".to_string())
})
- }).to_string().as_slice(),
+ }).to_string(),
"test = 2\n\
\n\
[test2]\n\
@@ -187,7 +187,7 @@ mod tests {
"test2" => Array(vec![Table(map! {
"test" => String("wut".to_string())
})])
- }).to_string().as_slice(),
+ }).to_string(),
"test = 2\n\
\n\
[[test2]]\n\
@@ -195,7 +195,7 @@ mod tests {
assert_eq!(Table(map! {
"foo.bar" => Integer(2),
"foo\"bar" => Integer(2)
- }).to_string().as_slice(),
+ }).to_string(),
"\"foo\\\"bar\" = 2\n\
\"foo.bar\" = 2\n");
}
diff --git a/src/lib.rs b/src/lib.rs
index afc102d..5c5fa91 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -34,10 +34,9 @@
//!
//! [1]: https://github.com/mojombo/toml
//! [2]: https://github.com/BurntSushi/toml-test
-//!
#![doc(html_root_url = "http://alexcrichton.com/toml-rs")]
-#![feature(collections, core)]
+#![feature(core)]
#![deny(missing_docs)]
#![cfg_attr(test, deny(warnings))]
@@ -209,7 +208,10 @@ impl FromStr for Value {
type Err = Vec<ParserError>;
fn from_str(s: &str) -> Result<Value, Vec<ParserError>> {
let mut p = Parser::new(s);
- p.parse().map(Value::Table).ok_or(p.errors)
+ match p.parse().map(Value::Table) {
+ Some(n) => Ok(n),
+ None => Err(p.errors),
+ }
}
}
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
}
diff --git a/src/serialization.rs b/src/serialization.rs
index a7ddaf3..03f9de3 100644
--- a/src/serialization.rs
+++ b/src/serialization.rs
@@ -1062,7 +1062,7 @@ mod tests {
match a {
Ok(..) => panic!("should not have decoded"),
Err(e) => {
- assert_eq!(format!("{}", e).as_slice(),
+ assert_eq!(format!("{}", e),
"expected a value of type `integer`, but \
found a value of type `float` for the key `bar`");
}
@@ -1080,7 +1080,7 @@ mod tests {
match a {
Ok(..) => panic!("should not have decoded"),
Err(e) => {
- assert_eq!(format!("{}", e).as_slice(),
+ assert_eq!(format!("{}", e),
"expected a value of type `integer` for the key `bar`");
}
}