Merge pull request #14 from dtolnay/grammar

Grammar in rustdoc
This commit is contained in:
Chen Yuheng 2016-03-10 20:54:07 +08:00
commit 776964a26c

View file

@ -7,7 +7,7 @@ use std::mem;
use parser::*; use parser::*;
use scanner::{TScalarStyle, ScanError, TokenType}; 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. /// access your YAML document.
/// ///
/// # Examples /// # Examples
@ -17,7 +17,7 @@ use scanner::{TScalarStyle, ScanError, TokenType};
/// let foo = Yaml::from_str("-123"); // convert the string to the appropriate YAML type /// let foo = Yaml::from_str("-123"); // convert the string to the appropriate YAML type
/// assert_eq!(foo.as_i64().unwrap(), -123); /// 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)]); /// let vec = Yaml::Array(vec![Yaml::Integer(1), Yaml::Integer(2)]);
/// for v in vec.as_vec().unwrap() { /// for v in vec.as_vec().unwrap() {
/// assert!(v.as_i64().is_some()); /// assert!(v.as_i64().is_some());
@ -25,26 +25,26 @@ use scanner::{TScalarStyle, ScanError, TokenType};
/// ``` /// ```
#[derive(Clone, PartialEq, PartialOrd, Debug, Eq, Ord)] #[derive(Clone, PartialEq, PartialOrd, Debug, Eq, Ord)]
pub enum Yaml { pub enum Yaml {
/// float types are stored as String, and parsed on demand. /// 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 /// Note that f64 does NOT implement Eq trait and can NOT be stored in BTreeMap.
Real(string::String), Real(string::String),
/// Yaml int is stored as i64. /// YAML int is stored as i64.
Integer(i64), Integer(i64),
/// Yaml scalar. /// YAML scalar.
String(string::String), String(string::String),
/// Yaml bool, e.g. `true` or `false`. /// YAML bool, e.g. `true` or `false`.
Boolean(bool), Boolean(bool),
/// Yaml array, can be access as a `Vec`. /// YAML array, can be accessed as a `Vec`.
Array(self::Array), Array(self::Array),
/// Yaml hash, can be access as a `BTreeMap`. /// YAML hash, can be accessed as a `BTreeMap`.
Hash(self::Hash), Hash(self::Hash),
/// Alias, not fully supported yet. /// Alias, not fully supported yet.
Alias(usize), Alias(usize),
/// Yaml bool, e.g. `null` or `~`. /// YAML null, e.g. `null` or `~`.
Null, Null,
/// Access non-exist node by Index trait will return `BadValue`. /// Accessing a nonexistent node via the Index trait returns `BadValue`. This
/// This simplifies error handling of user. Invalid type conversion /// simplifies error handling in the calling code. Invalid type conversion also
/// also return `BadValue`. /// returns `BadValue`.
BadValue, BadValue,
} }