to_string_with

Function to_string_with 

Source
pub fn to_string_with<T: ToRonDocument>(
    value: &T,
    config: &SerializeConfig,
) -> Result<String>
Expand description

Serialize a value to a RON string with custom settings.

If SerializeConfig::include_type_attribute is true (the default), the output will include a #![type = "..."] attribute using core::any::type_name.

ยงExample

use ron2::{to_string_with, SerializeConfig, Value};

let value = Value::Bool(true);

// With type attribute (default)
let ron = ron2::to_string_with(&value, &SerializeConfig::default())?;
assert!(ron.contains("#![type ="));
assert!(ron.contains("true"));

// Without type attribute
let ron = ron2::to_string_with(&value, &SerializeConfig::without_type_attribute())?;
assert_eq!(ron.trim(), "true");