From 6d28d041cfc86374bd3e77a88490a0e59ebb67bc Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 10 Mar 2016 01:55:21 -0800 Subject: [PATCH] Grammar in rustdoc --- parser/src/yaml.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/parser/src/yaml.rs b/parser/src/yaml.rs index 6db2a1b..92e053c 100644 --- a/parser/src/yaml.rs +++ b/parser/src/yaml.rs @@ -7,7 +7,7 @@ use std::mem; use parser::*; use scanner::{TScalarStyle, ScanError, TokenType}; -/// An YAML node is store as this `Yaml` enumeration, it provides an easy way to +/// A YAML node is stored as this `Yaml` enumeration, which provides an easy way to /// access your YAML document. /// /// # Examples @@ -17,7 +17,7 @@ use scanner::{TScalarStyle, ScanError, TokenType}; /// let foo = Yaml::from_str("-123"); // convert the string to the appropriate YAML type /// assert_eq!(foo.as_i64().unwrap(), -123); /// -/// // iterator over an Array +/// // iterate over an Array /// let vec = Yaml::Array(vec![Yaml::Integer(1), Yaml::Integer(2)]); /// for v in vec.as_vec().unwrap() { /// assert!(v.as_i64().is_some()); @@ -25,26 +25,26 @@ use scanner::{TScalarStyle, ScanError, TokenType}; /// ``` #[derive(Clone, PartialEq, PartialOrd, Debug, Eq, Ord)] pub enum Yaml { - /// float types are stored as String, and parsed on demand. - /// Note that f64 does NOT implement Eq trait and can NOT be stored in BTreeMap + /// Float types are stored as String and parsed on demand. + /// Note that f64 does NOT implement Eq trait and can NOT be stored in BTreeMap. Real(string::String), - /// Yaml int is stored as i64. + /// YAML int is stored as i64. Integer(i64), - /// Yaml scalar. + /// YAML scalar. String(string::String), - /// Yaml bool, e.g. `true` or `false`. + /// YAML bool, e.g. `true` or `false`. Boolean(bool), - /// Yaml array, can be access as a `Vec`. + /// YAML array, can be accessed as a `Vec`. Array(self::Array), - /// Yaml hash, can be access as a `BTreeMap`. + /// YAML hash, can be accessed as a `BTreeMap`. Hash(self::Hash), /// Alias, not fully supported yet. Alias(usize), - /// Yaml bool, e.g. `null` or `~`. + /// YAML null, e.g. `null` or `~`. Null, - /// Access non-exist node by Index trait will return `BadValue`. - /// This simplifies error handling of user. Invalid type conversion - /// also return `BadValue`. + /// Accessing a nonexistent node via the Index trait returns `BadValue`. This + /// simplifies error handling in the calling code. Invalid type conversion also + /// returns `BadValue`. BadValue, } @@ -250,13 +250,13 @@ impl Yaml { // This function falls back to Yaml::String if nothing else matches. pub fn from_str(v: &str) -> Yaml { if v.starts_with("0x") { - let n = i64::from_str_radix(&v[2..], 16); + let n = i64::from_str_radix(&v[2..], 16); if n.is_ok() { return Yaml::Integer(n.unwrap()); } } if v.starts_with("0o") { - let n = i64::from_str_radix(&v[2..], 8); + let n = i64::from_str_radix(&v[2..], 8); if n.is_ok() { return Yaml::Integer(n.unwrap()); }