Skip to main content

substrate_data/forms/text/writer/
to_string.rs

1//! A whole [`Value`] as text.
2
3use super::Writer;
4use crate::model::value::Value;
5
6/// `value` as compact text (typed values in their string forms).
7pub fn to_string(value: &Value) -> String {
8    let mut w = Writer::new();
9    w.value(value);
10    w.finish()
11}
12
13/// `value` as text indented by two spaces, one entry per line.
14pub fn to_string_pretty(value: &Value) -> String {
15    let mut w = Writer::pretty();
16    w.value(value);
17    w.finish()
18}