Skip to main content

to_string_pretty

Function to_string_pretty 

Source
pub fn to_string_pretty(table: &Table) -> String
Available on crate feature alloc only.
Expand description

Serializes a table as a TOML document, laid out for a human to read.

The document is the same as to_string writes; only the formatting of values differs. Arrays are spread one element per line, and a string holding a newline is written as a multi-line string rather than one long line of \n escapes.

let mut table = tomlproc::Table::new();
table.insert("ports", vec![8000, 8001]);

assert_eq!(tomlproc::to_string_pretty(&table), "ports = [\n    8000,\n    8001,\n]\n");