• Home
Name Date Size #Lines LOC

..--

examples/06-Sep-2024-285185

src/06-Sep-2024-11,4638,747

tests/06-Sep-2024-5,6945,064

.cargo_vcs_info.jsonD06-Sep-2024110 66

Android.bpD06-Sep-2024669 2725

Cargo.lockD06-Sep-202424 KiB927821

Cargo.tomlD06-Sep-20243.3 KiB181155

Cargo.toml.origD06-Sep-20242.6 KiB8069

LICENSED06-Sep-202411.7 KiB229188

LICENSE-APACHED06-Sep-202411.1 KiB203169

LICENSE-MITD06-Sep-20241 KiB2016

METADATAD06-Sep-2024711 2523

MODULE_LICENSE_APACHE2D06-Sep-20240

MODULE_LICENSE_MITD06-Sep-20240

OWNERSD06-Sep-202445 21

README.mdD06-Sep-20241.9 KiB5741

cargo_embargo.jsonD06-Sep-2024150 1312

README.md

1# toml_edit
2
3[![Build Status](https://github.com/toml-rs/toml/workflows/Continuous%20integration/badge.svg)](https://github.com/toml-rs/toml/actions)
4[![codecov](https://codecov.io/gh/toml-rs/toml/branch/master/graph/badge.svg)](https://codecov.io/gh/toml-rs/toml)
5[![crates.io](https://img.shields.io/crates/v/toml_edit.svg)](https://crates.io/crates/toml_edit)
6[![docs](https://docs.rs/toml_edit/badge.svg)](https://docs.rs/toml_edit)
7[![Join the chat at https://gitter.im/toml_edit/Lobby](https://badges.gitter.im/a.svg)](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