commit | 2eb4aad497ea33861179136909ff59a7108e6e0b | [log] [tgz] |
---|---|---|
author | James Farrell <[email protected]> | Wed Aug 07 20:52:12 2024 +0000 |
committer | Automerger Merge Worker <[email protected]> | Wed Aug 07 20:52:12 2024 +0000 |
tree | a49cee050ee018aab80eef9b2140687417bd31bb | |
parent | 0fc72f34a6dbd1e10a2791bf57550917a9a043fa [diff] | |
parent | 88395d501c196efae910dc4e73f36495276a4697 [diff] |
Update Android.bp by running cargo_embargo am: 88395d501c Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/toml_edit/+/3208387 Change-Id: Id2bddaa63e4f07950f82aa585a8e82cbc12d23ea Signed-off-by: Automerger Merge Worker <[email protected]>
This crate allows you to parse and modify toml documents, while preserving comments, spaces and relative order of items.
toml_edit
is primarily tailored for cargo-edit needs.
use toml_edit::{Document, value}; fn main() { let toml = r#" "hello" = 'toml!' # comment ['a'.b] "#; let mut doc = toml.parse::<Document>().expect("invalid doc"); assert_eq!(doc.to_string(), toml); // let's add a new key/value pair inside a.b: c = {d = "hello"} doc["a"]["b"]["c"]["d"] = value("hello"); // autoformat inline table a.b.c: { d = "hello" } doc["a"]["b"]["c"].as_inline_table_mut().map(|t| t.fmt()); let expected = r#" "hello" = 'toml!' # comment ['a'.b] c = { d = "hello" } "#; assert_eq!(doc.to_string(), expected); }
Things it does not preserve:
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.