Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
examples/ | 25-Apr-2025 | - | 285 | 185 | ||
patches/ | 25-Apr-2025 | - | 235 | 234 | ||
src/ | 25-Apr-2025 | - | 11,463 | 8,747 | ||
tests/ | 25-Apr-2025 | - | 5,694 | 5,064 | ||
.cargo-checksum.json | D | 25-Apr-2025 | 49.9 KiB | 1 | 1 | |
Android.bp | D | 25-Apr-2025 | 879 | 37 | 33 | |
Cargo.lock | D | 25-Apr-2025 | 24 KiB | 927 | 821 | |
Cargo.toml | D | 25-Apr-2025 | 3.3 KiB | 181 | 155 | |
LICENSE | D | 25-Apr-2025 | 11.7 KiB | 229 | 188 | |
LICENSE-APACHE | D | 25-Apr-2025 | 11.1 KiB | 203 | 169 | |
LICENSE-MIT | D | 25-Apr-2025 | 1 KiB | 20 | 16 | |
METADATA | D | 25-Apr-2025 | 388 | 18 | 17 | |
MODULE_LICENSE_APACHE2 | D | 25-Apr-2025 | 0 | |||
MODULE_LICENSE_MIT | D | 25-Apr-2025 | 0 | |||
README.md | D | 25-Apr-2025 | 1.9 KiB | 57 | 41 | |
cargo_embargo.json | D | 25-Apr-2025 | 150 | 13 | 12 |
README.md
1# toml_edit 2 3[](https://github.com/toml-rs/toml/actions) 4[](https://codecov.io/gh/toml-rs/toml) 5[](https://crates.io/crates/toml_edit) 6[](https://docs.rs/toml_edit) 7[](https://gitter.im/toml_edit/Lobby) 8 9 10This crate allows you to parse and modify toml 11documents, while preserving comments, spaces *and 12relative order* of items. 13 14`toml_edit` is primarily tailored for [cargo-edit](https://github.com/killercup/cargo-edit/) needs. 15 16## Example 17 18```rust 19use toml_edit::{Document, value}; 20 21fn main() { 22 let toml = r#" 23"hello" = 'toml!' # comment 24['a'.b] 25 "#; 26 let mut doc = toml.parse::<Document>().expect("invalid doc"); 27 assert_eq!(doc.to_string(), toml); 28 // let's add a new key/value pair inside a.b: c = {d = "hello"} 29 doc["a"]["b"]["c"]["d"] = value("hello"); 30 // autoformat inline table a.b.c: { d = "hello" } 31 doc["a"]["b"]["c"].as_inline_table_mut().map(|t| t.fmt()); 32 let expected = r#" 33"hello" = 'toml!' # comment 34['a'.b] 35c = { d = "hello" } 36 "#; 37 assert_eq!(doc.to_string(), expected); 38} 39``` 40 41## Limitations 42 43Things it does not preserve: 44 45* Order of dotted keys, see [issue](https://github.com/toml-rs/toml/issues/163). 46 47## License 48 49Licensed under either of 50 51- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://apache.org/licenses/LICENSE-2.0) 52- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 53 54### Contribution 55 56Unless 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. 57