Bump to 0.1.16

This commit is contained in:
Alex Crichton 2015-02-03 08:37:05 -08:00
parent ff8924a971
commit 0042025904
3 changed files with 10 additions and 8 deletions

View file

@ -1,7 +1,7 @@
[package] [package]
name = "toml" name = "toml"
version = "0.1.15" version = "0.1.16"
authors = ["Alex Crichton <alex@alexcrichton.com>"] authors = ["Alex Crichton <alex@alexcrichton.com>"]
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
readme = "README.md" readme = "README.md"

View file

@ -191,7 +191,7 @@ impl Value {
} }
}, },
&Value::Array(ref v) => { &Value::Array(ref v) => {
match key.parse::<usize>() { match key.parse::<usize>().ok() {
Some(idx) if idx < v.len() => cur_value = &v[idx], Some(idx) if idx < v.len() => cur_value = &v[idx],
_ => return None _ => return None
} }
@ -205,8 +205,10 @@ impl Value {
} }
impl FromStr for Value { impl FromStr for Value {
fn from_str(s: &str) -> Option<Value> { type Err = Vec<ParserError>;
Parser::new(s).parse().map(Value::Table) fn from_str(s: &str) -> Result<Value, Vec<ParserError>> {
let mut p = Parser::new(s);
p.parse().map(Value::Table).ok_or(p.errors)
} }
} }

View file

@ -132,7 +132,7 @@ impl<'a> Parser<'a> {
// Consumes the rest of the line after a comment character // Consumes the rest of the line after a comment character
fn comment(&mut self) -> bool { fn comment(&mut self) -> bool {
if !self.eat('#') { return false } if !self.eat('#') { return false }
for (_, ch) in self.cur { for (_, ch) in self.cur.by_ref() {
if ch == '\n' { break } if ch == '\n' { break }
} }
true true
@ -379,7 +379,7 @@ impl<'a> Parser<'a> {
} else { } else {
"invalid" "invalid"
}; };
match FromStrRadix::from_str_radix(num, 16) { match FromStrRadix::from_str_radix(num, 16).ok() {
Some(n) => { Some(n) => {
match char::from_u32(n) { match char::from_u32(n) {
Some(c) => { Some(c) => {
@ -497,9 +497,9 @@ impl<'a> Parser<'a> {
} else { } else {
let input = input.trim_left_matches('+'); let input = input.trim_left_matches('+');
if is_float { if is_float {
input.parse().map(Float) input.parse().ok().map(Float)
} else { } else {
input.parse().map(Integer) input.parse().ok().map(Integer)
} }
}; };
if ret.is_none() { if ret.is_none() {