• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

examples/25-Apr-2025-285185

patches/25-Apr-2025-235234

src/25-Apr-2025-11,4638,747

tests/25-Apr-2025-5,6945,064

.cargo-checksum.jsonD25-Apr-202549.9 KiB11

Android.bpD25-Apr-2025879 3733

Cargo.lockD25-Apr-202524 KiB927821

Cargo.tomlD25-Apr-20253.3 KiB181155

LICENSED25-Apr-202511.7 KiB229188

LICENSE-APACHED25-Apr-202511.1 KiB203169

LICENSE-MITD25-Apr-20251 KiB2016

METADATAD25-Apr-2025388 1817

MODULE_LICENSE_APACHE2D25-Apr-20250

MODULE_LICENSE_MITD25-Apr-20250

README.mdD25-Apr-20251.9 KiB5741

cargo_embargo.jsonD25-Apr-2025150 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