From 00420259044e9e961b9d8a80e5482ffc58250145 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 3 Feb 2015 08:37:05 -0800 Subject: Bump to 0.1.16 --- src/lib.rs | 8 +++++--- src/parser.rs | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 10e2009..89a72e7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -191,7 +191,7 @@ impl Value { } }, &Value::Array(ref v) => { - match key.parse::() { + match key.parse::().ok() { Some(idx) if idx < v.len() => cur_value = &v[idx], _ => return None } @@ -205,8 +205,10 @@ impl Value { } impl FromStr for Value { - fn from_str(s: &str) -> Option { - Parser::new(s).parse().map(Value::Table) + type Err = Vec; + fn from_str(s: &str) -> Result> { + let mut p = Parser::new(s); + p.parse().map(Value::Table).ok_or(p.errors) } } diff --git a/src/parser.rs b/src/parser.rs index 4316df3..723ac3a 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -132,7 +132,7 @@ impl<'a> Parser<'a> { // Consumes the rest of the line after a comment character fn comment(&mut self) -> bool { if !self.eat('#') { return false } - for (_, ch) in self.cur { + for (_, ch) in self.cur.by_ref() { if ch == '\n' { break } } true @@ -379,7 +379,7 @@ impl<'a> Parser<'a> { } else { "invalid" }; - match FromStrRadix::from_str_radix(num, 16) { + match FromStrRadix::from_str_radix(num, 16).ok() { Some(n) => { match char::from_u32(n) { Some(c) => { @@ -497,9 +497,9 @@ impl<'a> Parser<'a> { } else { let input = input.trim_left_matches('+'); if is_float { - input.parse().map(Float) + input.parse().ok().map(Float) } else { - input.parse().map(Integer) + input.parse().ok().map(Integer) } }; if ret.is_none() { -- cgit v1.2.3