commit | a4b14d3070566bb9f0d4554e88a09c029916a1f2 | [log] [tgz] |
---|---|---|
author | James Farrell <jamesfarrell@google.com> | Tue May 21 18:58:58 2024 +0000 |
committer | James Farrell <jamesfarrell@google.com> | Tue May 21 18:58:58 2024 +0000 |
tree | 96ecf424e86b5cd3dfe3461f1cfd5c76449035ff | |
parent | d3caacd55ecaf28f69cdb1fe3e06a356a604bc32 [diff] |
Update Android.bp by running cargo_embargo Test: ran cargo_embargo Change-Id: I6c3a96a0af7593d517fb2c7efbf37c47d9127301
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.