Skip to main content

dump_with

Function dump_with 

Source
pub fn dump_with(t: &Value, opts: Options) -> Result<String, SerError>
Expand description

Full serialization with extra options merged over the dump defaults.

§Errors

Propagates SerError from [serialize].

§Example

Build options over the dump defaults, then override what you need.

use serpent_serializer::{dump_with, Options};
use serpent_serializer::value::{Table, Value};

let t = Table::new();
t.push(Value::Number(1.0));
let opts = Options { maxnum: Some(1), ..Options::dump() };
let src = dump_with(&Value::Table(t), opts).unwrap();
assert_eq!(src, "do local _={1};return _;end");