tag | 187ded7658c209a957043f7b11ea02020a4817da | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Tue Apr 23 15:27:34 2024 -0700 |
object | 052abd9d6962f781bb155079b636e164c8c04856 |
Platform Tools Release 35.0.1 (11580240)
commit | 052abd9d6962f781bb155079b636e164c8c04856 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Thu Mar 07 02:18:05 2024 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Thu Mar 07 02:18:05 2024 +0000 |
tree | 68c2b5426766f3a2bc770792db8644d83602b4a5 | |
parent | 77cbc0c799d6d2a2de76746f44bc3014b6a39ba1 [diff] | |
parent | d3caacd55ecaf28f69cdb1fe3e06a356a604bc32 [diff] |
Snap for 11541002 from d3caacd55ecaf28f69cdb1fe3e06a356a604bc32 to sdk-release Change-Id: I81a073210c5e1f97a63f15e1c3635046020c81de
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.