Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #14 from dtolnay/grammar
Browse files Browse the repository at this point in the history
Grammar in rustdoc
  • Loading branch information
chenyh1990 committed Mar 10, 2016
2 parents f66a9c6 + fc0d070 commit e2b64c7
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,34 +17,34 @@ 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());
/// }
/// ```
#[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,
}

Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit e2b64c7

Please sign in to comment.