peek_to_string_pretty

Function peek_to_string_pretty 

Source
pub fn peek_to_string_pretty<'input, 'facet>(
    peek: Peek<'input, 'facet>,
) -> Result<String, SerializeError<JsonSerializeError>>
Expand description

Serialize a Peek instance to a pretty-printed JSON string.

ยงExample

use facet::Facet;
use facet_reflect::Peek;
use facet_json::peek_to_string_pretty;

#[derive(Facet)]
struct Point { x: i32, y: i32 }

let point = Point { x: 10, y: 20 };
let json = peek_to_string_pretty(Peek::new(&point)).unwrap();
assert!(json.contains('\n'));