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

Issue:
Improve the documentation
Add more examples to address https://github.com/ordian/toml_edit/issues/42.



Discussion / hints:

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 1dd05ff1..7fb850d3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "toml_edit"
-version = "0.1.1"
+version = "0.1.2"
 readme = "README.md"
 license = "MIT/Apache-2.0"
 keywords = ["toml"]
diff --git a/src/table.rs b/src/table.rs
index 3bd5dbf1..e486e2f8 100644
--- a/src/table.rs
+++ b/src/table.rs
@@ -380,6 +380,30 @@ impl TableLike for Table {
 }
 
 /// Returns a formatted value.
+///
+/// Since formatting is part of a `Value`, the right hand side of the
+/// assignment needs to be decorated with a space before the value.
+/// The `value` function does just that.
+///
+/// # Examples
+/// ```rust
+/// # extern crate toml_edit;
+/// # use toml_edit::*;
+/// # fn main() {
+/// let mut table = Table::default();
+/// let mut array = Array::default();
+/// array.push("hello");
+/// array.push("\\, world"); // \ is only allowed in a literal string
+/// table["key1"] = value("value1");
+/// table["key2"] = value(42);
+/// table["key3"] = value(array);
+/// assert_eq!(table.to_string(),
+/// r#"key1 = "value1"
+/// key2 = 42
+/// key3 = ["hello", '\, world']
+/// "#);
+/// # }
+/// ```
 pub fn value<V: Into<Value>>(v: V) -> Item {
     Item::Value(decorated(v.into(), " ", ""))
 }


Test patch: