From 9d761f5614c262ac79f8c1e6d90023a5f869e246 Mon Sep 17 00:00:00 2001 From: Colin Kiegel Date: Wed, 5 Apr 2017 20:51:36 +0200 Subject: [PATCH 1/4] doc - group link definitions --- src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4a27c7c..0ac69fe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,5 @@ //! A [TOML]-parsing library //! -//! [TOML]: https://github.com/toml-lang/toml -//! //! This library implements a [TOML] v0.4.0 compatible parser, //! primarily supporting the [`serde`] library for encoding/decoding //! various types in Rust. @@ -146,6 +144,7 @@ //! } //! ``` //! +//! [TOML]: https://github.com/toml-lang/toml //! [Cargo]: https://crates.io/ //! [`serde`]: https://serde.rs/ From 44c738acfd7587ebf4f0d355af24dde168d4519e Mon Sep 17 00:00:00 2001 From: Colin Kiegel Date: Wed, 5 Apr 2017 21:05:35 +0200 Subject: [PATCH 2/4] travis - run tests on 1.15.0 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a7c4b12..c9e484b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: rust rust: + - 1.15.0 - stable - beta - nightly From 36b9b268ba18c6a52a9ae97b53b16f3c3b502c10 Mon Sep 17 00:00:00 2001 From: Colin Kiegel Date: Wed, 5 Apr 2017 21:24:11 +0200 Subject: [PATCH 3/4] remove deadcode (unused since e256931e9bc3d04ae93) --- src/value/display.rs | 134 ------------------------------------------- 1 file changed, 134 deletions(-) delete mode 100644 src/value/display.rs diff --git a/src/value/display.rs b/src/value/display.rs deleted file mode 100644 index 0a6365d..0000000 --- a/src/value/display.rs +++ /dev/null @@ -1,134 +0,0 @@ -use std::fmt; - -use Table as TomlTable; -use Value::{self, String, Integer, Float, Boolean, Datetime, Array, Table}; - -struct Printer<'a, 'b:'a> { - output: &'a mut fmt::Formatter<'b>, - stack: Vec<&'a str>, -} - -struct Key<'a>(&'a [&'a str]); - -impl fmt::Display for Value { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - String(ref s) => write_str(f, s), - Integer(i) => write!(f, "{}", i), - Float(fp) => { - try!(write!(f, "{}", fp)); - if fp % 1.0 == 0.0 { try!(write!(f, ".0")) } - Ok(()) - } - Boolean(b) => write!(f, "{}", b), - Datetime(ref s) => write!(f, "{}", s), - Table(ref t) => { - let mut p = Printer { output: f, stack: Vec::new() }; - p.print(t) - } - Array(ref a) => { - try!(write!(f, "[")); - for (i, v) in a.iter().enumerate() { - if i != 0 { try!(write!(f, ", ")); } - try!(write!(f, "{}", v)); - } - write!(f, "]") - } - } - } -} - -fn write_str(f: &mut fmt::Formatter, s: &str) -> fmt::Result { - try!(write!(f, "\"")); - for ch in s.chars() { - match ch { - '\u{8}' => try!(write!(f, "\\b")), - '\u{9}' => try!(write!(f, "\\t")), - '\u{a}' => try!(write!(f, "\\n")), - '\u{c}' => try!(write!(f, "\\f")), - '\u{d}' => try!(write!(f, "\\r")), - '\u{22}' => try!(write!(f, "\\\"")), - '\u{5c}' => try!(write!(f, "\\\\")), - c if c < '\u{1f}' => { - try!(write!(f, "\\u{:04}", ch as u32)) - } - ch => try!(write!(f, "{}", ch)), - } - } - write!(f, "\"") -} - -impl<'a, 'b> Printer<'a, 'b> { - fn print(&mut self, table: &'a TomlTable) -> fmt::Result { - let mut space_out_first = false; - for (k, v) in table.iter() { - match *v { - Table(..) => continue, - Array(ref a) => { - if let Some(&Table(..)) = a.first() { - continue; - } - } - _ => {} - } - space_out_first = true; - try!(writeln!(self.output, "{} = {}", Key(&[k]), v)); - } - for (i, (k, v)) in table.iter().enumerate() { - match *v { - Table(ref inner) => { - self.stack.push(k); - if space_out_first || i != 0 { - try!(write!(self.output, "\n")); - } - try!(writeln!(self.output, "[{}]", Key(&self.stack))); - try!(self.print(inner)); - self.stack.pop(); - } - Array(ref inner) => { - match inner.first() { - Some(&Table(..)) => {} - _ => continue - } - self.stack.push(k); - for (j, inner) in inner.iter().enumerate() { - if space_out_first || i != 0 || j != 0 { - try!(write!(self.output, "\n")); - } - try!(writeln!(self.output, "[[{}]]", Key(&self.stack))); - match *inner { - Table(ref inner) => try!(self.print(inner)), - _ => panic!("non-heterogeneous toml array"), - } - } - self.stack.pop(); - } - _ => {}, - } - } - Ok(()) - } -} - -impl<'a> fmt::Display for Key<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - for (i, part) in self.0.iter().enumerate() { - if i != 0 { try!(write!(f, ".")); } - let ok = part.chars().all(|c| { - match c { - 'a' ... 'z' | - 'A' ... 'Z' | - '0' ... '9' | - '-' | '_' => true, - _ => false, - } - }); - if ok { - try!(write!(f, "{}", part)); - } else { - try!(write_str(f, part)); - } - } - Ok(()) - } -} From 22168aa100dc249b9c6e3907194fa149c148b894 Mon Sep 17 00:00:00 2001 From: Colin Kiegel Date: Wed, 5 Apr 2017 21:30:32 +0200 Subject: [PATCH 4/4] group mod statements consistently --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0ac69fe..7b72eac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,9 +155,9 @@ extern crate serde; pub mod value; -mod datetime; #[doc(no_inline)] pub use value::Value; +mod datetime; pub mod ser; #[doc(no_inline)]