Function yaml_peg::dumper::dump

source ยท
pub fn dump<R: Repr>(nodes: &[Node<R>], anchors: &[Anchors<R>]) -> String
Expand description

Dump the YAML data in to block format.

Dumper will use plain string when the string is none-wrapped, otherwise it use literal string and trim the last white spaces.

use yaml_peg::{dump, node, dumper::NL};

let doc = dump(&[
    node!({
        "a" => "b",
        "c" => "d",
    }),
], &[]);
let ans = "\
a: b
c: d
";
assert_eq!(doc, ans.replace('\n', NL));

When calling parse function then dump the string, the string can be reformatted.

Anchors can pass with the result of the Loader.