Repository: toml-rs/toml (language: rust)

Issue:
Documentation
- [x] Document all public API
- [x] enable `#[deny(missing_docs)]


Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index fe0a2a18..ac472002 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,6 @@
 [![crates.io](https://img.shields.io/crates/v/toml_edit.svg)](https://crates.io/crates/toml_edit)
 [![docs](https://docs.rs/toml_edit/badge.svg)](https://docs.rs/toml_edit/badge.svg)
 [![Join the chat at https://gitter.im/toml_edit/Lobby](https://badges.gitter.im/a.svg)](https://gitter.im/toml_edit/Lobby)
-[docs](https://reusable.software/rust/toml_edit/doc/toml_edit/index.html)
 
 
 This crate allows you to parse and modify toml
diff --git a/src/array_of_tables.rs b/src/array_of_tables.rs
index 298c99f0..2fdd1642 100644
--- a/src/array_of_tables.rs
+++ b/src/array_of_tables.rs
@@ -7,38 +7,43 @@ pub struct ArrayOfTables {
     pub(crate) values: Vec<Item>,
 }
 
+/// An iterator type over `ArrayOfTables`'s values.
 type ArrayOfTablesIter<'a> = Box<Iterator<Item = &'a Table> + 'a>;
 
 impl ArrayOfTables {
+    /// Creates an empty array of tables.
     pub fn new() -> Self {
         Default::default()
     }
 
-    /// Returns an iterator over tables
+    /// Returns an iterator over tables.
     pub fn iter(&self) -> ArrayOfTablesIter {
         Box::new(self.values.iter().filter_map(Item::as_table))
     }
 
-    /// Returns an optional reference to the table
+    /// Returns an optional reference to the table.
     pub fn get(&self, index: usize) -> Option<&Table> {
         self.values.get(index).and_then(Item::as_table)
     }
 
-    /// Returns an optional mutable reference to the table
+    /// Returns an optional mutable reference to the table.
     pub fn get_mut(&mut self, index: usize) -> Option<&mut Table> {
         self.values.get_mut(index).and_then(Item::as_table_mut)
     }
 
+    /// Appends a table to the array.
     pub fn append(&mut self, table: Table) -> &mut Table {
         self.values.push(Item::Table(table));
         let i = self.len() - 1;
         self.get_mut(i).unwrap()
     }
 
+    /// Removes a table with the given index.
     pub fn remove(&mut self, index: usize) {
         self.values.remove(index);
     }
 
+    /// Removes all the tables.
     pub fn clear(&mut self) {
         self.values.clear()
     }
@@ -49,7 +54,7 @@ impl ArrayOfTables {
         self.values.len()
     }
 
-    /// Return true iff `self.len() == 0`
+    /// Returns true iff `self.len() == 0`.
     pub fn is_empty(&self) -> bool {
         self.len() == 0
     }
diff --git a/src/document.rs b/src/document.rs
index 8e424c64..10621470 100644
--- a/src/document.rs
+++ b/src/document.rs
@@ -28,16 +28,19 @@ impl Document {
         Default::default()
     }
 
+    /// Returns a reference to the root table.
     pub fn as_table(&self) -> &Table {
         self.root.as_table().expect("root should always be a table")
     }
 
+    /// Returns a mutable reference to the root table.
     pub fn as_table_mut(&mut self) -> &mut Table {
         self.root
             .as_table_mut()
             .expect("root should always be a table")
     }
 
+    /// Returns an iterator over the root table.
     pub fn iter(&self) -> Iter {
         self.root
             .as_table()
diff --git a/src/key.rs b/src/key.rs
index 66182d67..8c99501f 100644
--- a/src/key.rs
+++ b/src/key.rs
@@ -67,10 +67,12 @@ impl Key {
         }
     }
 
+    /// Returns the parsed key value.
     pub fn get(&self) -> &str {
         &self.key
     }
 
+    /// Returns the key raw representation.
     pub fn raw(&self) -> &str {
         &self.raw
     }
diff --git a/src/lib.rs b/src/lib.rs
index 4acd21df..ded1d18f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,11 +1,11 @@
-// #![deny(missing_docs)]
-// #![deny(warnings)]
+#![deny(missing_docs)]
+#![deny(warnings)]
 
 //! # `toml_edit`
 //!
 //! This crate allows you to parse and modify toml
-//! documents, while *mostly* preserving comments, spaces and
-//! relative order or items.
+//! documents, while preserving comments, spaces* and
+//! relative order* or items.
 //!
 //! It is primarily tailored to the needs of [cargo-edit](https://github.com/killercup/cargo-edit/).
 //!
@@ -35,6 +35,32 @@
 //!     assert_eq!(doc.to_string(), expected);
 //! }
 //! ```
+//!
+//! ## Limitations
+//!
+//! *Things it does not preserve:
+//! 1. Different quotes and spaces around the same table key, e.g.
+//!     ```toml
+//!     [ 'a'. b]
+//!     [ "a"  .c]
+//!     [a.d]
+//!     ```
+//!     will be represented as (spaces are removed, the first encountered quote type is used)
+//!     ```toml
+//!     ['a'.b]
+//!     ['a'.c]
+//!     ['a'.d]
+//!     ```
+//! 2. Children tables before parent table (tables are reordered, see [test]).
+//! 3. Scattered array of tables (tables are reordered, see [test]).
+//!
+//! The reason behind the first limitation is that `Table` does not store its header,
+//! allowing us to safely swap two tables
+//! (we store a mapping in each table: child key -> child table).
+//!
+//! This last two limitations allow us to represent a toml document as a tree-like data structure,
+//! which enables easier implementation of editing operations
+//! and an easy to use and type-safe API.
 extern crate chrono;
 #[macro_use]
 extern crate combine;
diff --git a/src/table.rs b/src/table.rs
index 54fc6003..3470f37b 100644
--- a/src/table.rs
+++ b/src/table.rs
@@ -6,7 +6,6 @@ use array_of_tables::ArrayOfTables;
 use formatted::{decorated, key_repr};
 
 // TODO: add method to convert a table into inline table
-// TODO: documentation
 
 /// Type representing a TOML non-inline table
 #[derive(Clone, Debug, Default)]
@@ -20,11 +19,16 @@ pub struct Table {
 
 pub(crate) type KeyValuePairs = LinkedHashMap<InternalString, TableKeyValue>;
 
+/// Type representing either a value, a table, an array of tables, or none.
 #[derive(Debug, Clone)]
 pub enum Item {
+    /// Type representing none.
     None,
+    /// Type representing value.
     Value(Value),
+    /// Type representing table.
     Table(Table),
+    /// Type representing array of tables.
     ArrayOfTables(ArrayOfTables),
 }
 
@@ -51,9 +55,11 @@ impl TableKeyValue {
     }
 }
 
+/// An iterator type over `Table`'s key/value pairs.
 pub type Iter<'a> = Box<Iterator<Item = (&'a str, &'a Item)> + 'a>;
 
 impl Table {
+    /// Creates an empty table.
     pub fn new() -> Self {
         Self::with_decor(Decor::new("\n", ""))
     }
@@ -65,6 +71,7 @@ impl Table {
         }
     }
 
+    /// Returns true iff the table contains an item with the given key.
     pub fn contains_key(&self, key: &str) -> bool {
         if let Some(kv) = self.items.get(key) {
             !kv.value.is_none()
@@ -73,6 +80,7 @@ impl Table {
         }
     }
 
+    /// Returns true iff the table contains a table with the given key.
     pub fn contains_table(&self, key: &str) -> bool {
         if let Some(kv) = self.items.get(key) {
             kv.value.is_table()
@@ -81,6 +89,7 @@ impl Table {
         }
     }
 
+    /// Returns true iff the table contains a value with the given key.
     pub fn contains_value(&self, key: &str) -> bool {
         if let Some(kv) = self.items.get(key) {
             kv.value.is_value()
@@ -89,6 +98,7 @@ impl Table {
         }
     }
 
+    /// Returns true iff the table contains an array of tables with the given key.
     pub fn contains_array_of_tables(&self, key: &str) -> bool {
         if let Some(kv) = self.items.get(key) {
             kv.value.is_array_of_tables()
@@ -97,10 +107,12 @@ impl Table {
         }
     }
 
+    /// Returns an iterator over all key/value pairs, including empty.
     pub fn iter(&self) -> Iter {
         Box::new(self.items.iter().map(|(key, kv)| (&key[..], &kv.value)))
     }
 
+    /// Removes an item given the key.
     pub fn remove(&mut self, key: &str) -> Option<Item> {
         self.items.remove(key).map(|kv| kv.value)
     }
@@ -121,6 +133,7 @@ impl Table {
         self.items.iter().filter(|i| (i.1).value.is_value()).count()
     }
 
+    /// Returns true iff the table is empty.
     pub fn is_empty(&self) -> bool {
         self.len() == 0
     }
@@ -139,6 +152,7 @@ impl Table {
             .value
     }
 
+    /// Returns an optional reference to an item given the key.
     pub fn get<'a>(&'a self, key: &str) -> Option<&'a Item> {
         self.items.get(key).map(|kv| &kv.value)
     }
@@ -170,6 +184,8 @@ impl Table {
 }
 
 impl Item {
+    /// Sets `self` to the given item iff `self` is none and
+    /// returns a mutable reference to `self`.
     pub fn or_insert(&mut self, item: Item) -> &mut Item {
         if self.is_none() {
             *self = item
@@ -180,51 +196,61 @@ impl Item {
 // TODO: This should be generated by macro or derive
 /// Downcasting
 impl Item {
+    /// Casts `self` to value.
     pub fn as_value(&self) -> Option<&Value> {
         match *self {
             Item::Value(ref v) => Some(v),
             _ => None,
         }
     }
+    /// Casts `self` to table.
     pub fn as_table(&self) -> Option<&Table> {
         match *self {
             Item::Table(ref t) => Some(t),
             _ => None,
         }
     }
+    /// Casts `self` to array of tables.
     pub fn as_array_of_tables(&self) -> Option<&ArrayOfTables> {
         match *self {
             Item::ArrayOfTables(ref a) => Some(a),
             _ => None,
         }
     }
+    /// Casts `self` to mutable value.
     pub fn as_value_mut(&mut self) -> Option<&mut Value> {
         match *self {
             Item::Value(ref mut v) => Some(v),
             _ => None,
         }
     }
+    /// Casts `self` to mutable table.
     pub fn as_table_mut(&mut self) -> Option<&mut Table> {
         match *self {
             Item::Table(ref mut t) => Some(t),
             _ => None,
         }
     }
+    /// Casts `self` to mutable array of tables.
     pub fn as_array_of_tables_mut(&mut self) -> Option<&mut ArrayOfTables> {
         match *self {
             Item::ArrayOfTables(ref mut a) => Some(a),
             _ => None,
         }
     }
+    /// Returns true iff `self` is a value.
     pub fn is_value(&self) -> bool {
         self.as_value().is_some()
     }
+    /// Returns true iff `self` is a table.
     pub fn is_table(&self) -> bool {
         self.as_table().is_some()
     }
+    /// Returns true iff `self` is an array of tables.
     pub fn is_array_of_tables(&self) -> bool {
         self.as_array_of_tables().is_some()
     }
+    /// Returns true iff `self` is `None`.
     pub fn is_none(&self) -> bool {
         match *self {
             Item::None => true,
@@ -234,91 +260,112 @@ impl Item {
 
     // Duplicate Value downcasting API
 
+    /// Casts `self` to integer.
     pub fn as_integer(&self) -> Option<i64> {
         self.as_value().and_then(|v| v.as_integer())
     }
 
+    /// Returns true iff `self` is an integer.
     pub fn is_integer(&self) -> bool {
         self.as_integer().is_some()
     }
 
+    /// Casts `self` to float.
     pub fn as_float(&self) -> Option<f64> {
         self.as_value().and_then(|v| v.as_float())
     }
 
+    /// Returns true iff `self` is a float.
     pub fn is_float(&self) -> bool {
         self.as_float().is_some()
     }
 
+    /// Casts `self` to boolean.
     pub fn as_bool(&self) -> Option<bool> {
         self.as_value().and_then(|v| v.as_bool())
     }
 
+    /// Returns true iff `self` is a boolean.
     pub fn is_bool(&self) -> bool {
         self.as_bool().is_some()
     }
 
+    /// Casts `self` to str.
     pub fn as_str(&self) -> Option<&str> {
         self.as_value().and_then(|v| v.as_str())
     }
 
+    /// Returns true iff `self` is a string.
     pub fn is_str(&self) -> bool {
         self.as_str().is_some()
     }
 
+    /// Casts `self` to date-time.
     pub fn as_date_time(&self) -> Option<&DateTime> {
         self.as_value().and_then(|v| v.as_date_time())
     }
 
+    /// Returns true iff `self` is a date-time.
     pub fn is_date_time(&self) -> bool {
         self.as_date_time().is_some()
     }
 
+    /// Casts `self` to array.
     pub fn as_array(&self) -> Option<&Array> {
         self.as_value().and_then(|v| v.as_array())
     }
 
+    /// Casts `self` to mutable array.
     pub fn as_array_mut(&mut self) -> Option<&mut Array> {
         self.as_value_mut().and_then(|v| v.as_array_mut())
     }
 
+    /// Returns true iff `self` is an array.
     pub fn is_array(&self) -> bool {
         self.as_array().is_some()
     }
 
+    /// Casts `self` to inline table.
     pub fn as_inline_table(&self) -> Option<&InlineTable> {
         self.as_value().and_then(|v| v.as_inline_table())
     }
 
+    /// Casts `self` to mutable inline table.
     pub fn as_inline_table_mut(&mut self) -> Option<&mut InlineTable> {
         self.as_value_mut().and_then(|v| v.as_inline_table_mut())
     }
 
+    /// Returns true iff `self` is an inline table.
     pub fn is_inline_table(&self) -> bool {
         self.as_inline_table().is_some()
     }
 
-    /// Returns None iff the item is neither `Table`, nor `InlineTable`.
+    /// Casts `self` to either a table or an inline table.
     pub fn as_table_like(&self) -> Option<&TableLike> {
         self.as_table()
             .map(|t| t as &TableLike)
             .or_else(|| self.as_inline_table().map(|t| t as &TableLike))
     }
 
+    /// Returns true iff `self` is either a table, or an inline table.
     pub fn is_table_like(&self) -> bool {
         self.as_table_like().is_some()
     }
 }
 
+/// This trait represents either a `Table`, or an `InlineTable`.
 pub trait TableLike {
+    /// Returns an iterator over key/value pairs.
     fn iter(&self) -> Iter;
-    /// Return the number of nonempty items
+    /// Returns the number of nonempty items.
     fn len(&self) -> usize {
         self.iter().filter(|&(_, v)| !v.is_none()).count()
     }
+    /// Returns true iff the table is empty.
     fn is_empty(&self) -> bool {
         self.len() == 0
     }
+    /// Returns an optional reference to an item given the key.
     fn get<'s>(&'s self, key: &str) -> Option<&'s Item>;
 }
 
@@ -332,14 +379,17 @@ impl TableLike for Table {
     }
 }
 
+/// Returns a formatted value.
 pub fn value<V: Into<Value>>(v: V) -> Item {
     Item::Value(decorated(v.into(), " ", ""))
 }
 
+/// Returns an empty table.
 pub fn table() -> Item {
     Item::Table(Table::new())
 }
 
+/// Returns an empty array of tables.
 pub fn array() -> Item {
     Item::ArrayOfTables(ArrayOfTables::new())
 }
diff --git a/src/value.rs b/src/value.rs
index 469352ea..506ed56f 100644
--- a/src/value.rs
+++ b/src/value.rs
@@ -14,12 +14,19 @@ use combine::Parser;
 /// Representation of a TOML Value (as part of a Key/Value Pair).
 #[derive(Debug, Clone)]
 pub enum Value {
+    /// A 64-bit integer value.
     Integer(Formatted<i64>),
+    /// A string value.
     String(Formatted<String>),
+    /// A 64-bit float value.
     Float(Formatted<f64>),
+    /// A Date-Time value.
     DateTime(Formatted<DateTime>),
+    /// A boolean value.
     Boolean(Formatted<bool>),
+    /// An inline array of values.
     Array(Array),
+    /// An inline table of key/value pairs.
     InlineTable(InlineTable),
 }
 
@@ -27,9 +34,13 @@ pub enum Value {
 /// payload of the `Value::DateTime` variant's value
 #[derive(Eq, PartialEq, Clone, Debug, Hash)]
 pub enum DateTime {
+    /// An RFC 3339 formatted date-time with offset.
     OffsetDateTime(chrono::DateTime<FixedOffset>),
+    /// An RFC 3339 formatted date-time without offset.
     LocalDateTime(chrono::NaiveDateTime),
+    /// Date portion of an RFC 3339 formatted date-time.
     LocalDate(chrono::NaiveDate),
+    /// Time portion of an RFC 3339 formatted date-time.
     LocalTime(chrono::NaiveTime),
 }
 
@@ -70,6 +81,7 @@ pub(crate) enum ValueType {
     InlineTable,
 }
 
+/// An iterator type over `Array`'s values.
 pub type ArrayIter<'a> = Box<Iterator<Item = &'a Value> + 'a>;
 
 impl Array {
@@ -79,23 +91,27 @@ impl Array {
         self.values.len()
     }
 
-    /// Return true iff `self.len() == 0`
+    /// Return true iff `self.len() == 0`.
     pub fn is_empty(&self) -> bool {
         self.len() == 0
     }
 
+    /// Returns an iterator over all values.
     pub fn iter(&self) -> ArrayIter {
         Box::new(self.values.iter().filter_map(|i| i.as_value()))
     }
 
+    /// Appends a new value.
     pub fn push<V: Into<Value>>(&mut self, v: V) -> bool {
         self.push_value(v.into(), true)
     }
 
+    /// Return an optional reference to the value at the given index.
     pub fn get(&mut self, index: usize) -> Option<&Value> {
         self.values.get(index).and_then(Item::as_value)
     }
 
+    /// Removes the value at the given index.
     pub fn remove(&mut self, index: usize) -> Value {
         let removed = self.values.remove(index);
         if self.is_empty() {
@@ -107,7 +123,7 @@ impl Array {
         }
     }
 
-    /// Auto formats the array
+    /// Auto formats the array.
     pub fn fmt(&mut self) {
         formatted::decorate_array(self);
     }
@@ -136,17 +152,21 @@ impl Array {
     }
 }
 
+/// An iterator type over key/value pairs of an inline table.
 pub type InlineTableIter<'a> = Box<Iterator<Item = (&'a str, &'a Value)> + 'a>;
 
 impl InlineTable {
+    /// Returns the number of key/value pairs.
     pub fn len(&self) -> usize {
         self.iter().count()
     }
 
+    /// Returns true iff the table is empty.
     pub fn is_empty(&self) -> bool {
         self.len() == 0
     }
 
+    /// Returns an iterator over key/value pairs.
     pub fn iter(&self) -> InlineTableIter {
         Box::new(
             self.items
@@ -156,10 +176,12 @@ impl InlineTable {
         )
     }
 
+    /// Sorts the key/value pairs by key.
     pub fn sort(&mut self) {
         sort_key_value_pairs(&mut self.items);
     }
 
+    /// Returns true iff the table contains given key.
     pub fn contains_key(&self, key: &str) -> bool {
         if let Some(kv) = self.items.get(key) {
             !kv.value.is_none()
@@ -168,6 +190,8 @@ impl InlineTable {
         }
     }
 
+    /// Merges the key/value pairs into the `other` table leaving
+    /// `self` empty.
     pub fn merge_into(&mut self, other: &mut InlineTable) {
         let items = mem::replace(&mut self.items, KeyValuePairs::new());
         for (k, kv) in items {
@@ -175,6 +199,8 @@ impl InlineTable {
         }
     }
 
+    /// Inserts a key/value pair if the table does not contain the key.
+    /// Returns a mutable reference to the corresponding value.
     pub fn get_or_insert<V: Into<Value>>(&mut self, key: &str, value: V) -> &mut Value {
         let parsed = key.parse::<Key>().expect("invalid key");
         self.items
@@ -185,21 +211,24 @@ impl InlineTable {
             .expect("non-value type in inline table")
     }
 
-    /// Auto formats the table
+    /// Auto formats the table.
     pub fn fmt(&mut self) {
         formatted::decorate_inline_table(self);
     }
 
+    /// Removes a key/value pair given the key.
     pub fn remove(&mut self, key: &str) -> Option<Value> {
         self.items
             .remove(key)
             .and_then(|kv| kv.value.as_value().cloned())
     }
 
+    /// Return an optional reference to the value at the given the key.
     pub fn get(&self, key: &str) -> Option<&Value> {
         self.items.get(key).and_then(|kv| kv.value.as_value())
     }
 
+    /// Return an optional mutable reference to the value at the given the key.
     pub fn get_mut(&mut self, key: &str) -> Option<&mut Value> {
         self.items
             .get_mut(key)
@@ -218,39 +247,47 @@ impl TableLike for InlineTable {
 
 /// Downcasting
 impl DateTime {
+    /// Casts `self` to offset date-time.
     pub fn as_offset_date_time(&self) -> Option<&chrono::DateTime<FixedOffset>> {
         match *self {
             DateTime::OffsetDateTime(ref dt) => Some(dt),
             _ => None,
         }
     }
+    /// Casts `self` to local date-time.
     pub fn as_local_date_time(&self) -> Option<&chrono::NaiveDateTime> {
         match *self {
             DateTime::LocalDateTime(ref dt) => Some(dt),
             _ => None,
         }
     }
+    /// Casts `self` to local date.
     pub fn as_local_date(&self) -> Option<&chrono::NaiveDate> {
         match *self {
             DateTime::LocalDate(ref d) => Some(d),
             _ => None,
         }
     }
+    /// Casts `self` to local time.
     pub fn as_local_time(&self) -> Option<&chrono::NaiveTime> {
         match *self {
             DateTime::LocalTime(ref t) => Some(t),
             _ => None,
         }
     }
+    /// Returns true iff `self` is an offset date-time.
     pub fn is_offset_date_time(&self) -> bool {
         self.as_offset_date_time().is_some()
     }
+    /// Returns true iff `self` is a local date-time.
     pub fn is_local_date_time(&self) -> bool {
         self.as_local_date_time().is_some()
     }
+    /// Returns true iff `self` is a local date.
     pub fn is_local_date(&self) -> bool {
         self.as_local_date().is_some()
     }
+    /// Returns true iff `self` is a local time.
     pub fn is_local_time(&self) -> bool {
         self.as_local_time().is_some()
     }
@@ -258,6 +295,7 @@ impl DateTime {
 
 /// Downcasting
 impl Value {
+    /// Casts `self` to integer.
     pub fn as_integer(&self) -> Option<i64> {
         match *self {
             Value::Integer(ref value) => Some(*value.value()),
@@ -265,10 +303,12 @@ impl Value {
         }
     }
 
+    /// Returns true iff `self` is an integer.
     pub fn is_integer(&self) -> bool {
         self.as_integer().is_some()
     }
 
+    /// Casts `self` to float.
     pub fn as_float(&self) -> Option<f64> {
         match *self {
             Value::Float(ref value) => Some(*value.value()),
@@ -276,10 +316,12 @@ impl Value {
         }
     }
 
+    /// Returns true iff `self` is a float.
     pub fn is_float(&self) -> bool {
         self.as_float().is_some()
     }
 
+    /// Casts `self` to boolean.
     pub fn as_bool(&self) -> Option<bool> {
         match *self {
             Value::Boolean(ref value) => Some(*value.value()),
@@ -287,10 +329,12 @@ impl Value {
         }
     }
 
+    /// Returns true iff `self` is a boolean.
     pub fn is_bool(&self) -> bool {
         self.as_bool().is_some()
     }
 
+    /// Casts `self` to str.
     pub fn as_str(&self) -> Option<&str> {
         match *self {
             Value::String(ref value) => Some(value.value()),
@@ -298,10 +342,12 @@ impl Value {
         }
     }
 
+    /// Returns true iff `self` is a string.
     pub fn is_str(&self) -> bool {
         self.as_str().is_some()
     }
 
+    /// Casts `self` to date-time.
     pub fn as_date_time(&self) -> Option<&DateTime> {
         match *self {
             Value::DateTime(ref value) => Some(value.value()),
@@ -309,10 +355,12 @@ impl Value {
         }
     }
 
+    /// Returns true iff `self` is a date-time.
     pub fn is_date_time(&self) -> bool {
         self.as_date_time().is_some()
     }
 
+    /// Casts `self` to array.
     pub fn as_array(&self) -> Option<&Array> {
         match *self {
             Value::Array(ref value) => Some(value),
@@ -320,6 +368,7 @@ impl Value {
         }
     }
 
+    /// Casts `self` to mutable array.
     pub fn as_array_mut(&mut self) -> Option<&mut Array> {
         match *self {
             Value::Array(ref mut value) => Some(value),
@@ -327,10 +376,12 @@ impl Value {
         }
     }
 
+    /// Returns true iff `self` is an array.
     pub fn is_array(&self) -> bool {
         self.as_array().is_some()
     }
 
+    /// Casts `self` to inline table.
     pub fn as_inline_table(&self) -> Option<&InlineTable> {
         match *self {
             Value::InlineTable(ref value) => Some(value),
@@ -338,6 +389,7 @@ impl Value {
         }
     }
 
+    /// Casts `self` to mutable inline table.
     pub fn as_inline_table_mut(&mut self) -> Option<&mut InlineTable> {
         match *self {
             Value::InlineTable(ref mut value) => Some(value),
@@ -345,6 +397,7 @@ impl Value {
         }
     }
 
+    /// Returns true iff `self` is an inline table.
     pub fn is_inline_table(&self) -> bool {
         self.as_inline_table().is_some()
     }


Test patch: