pub fn minify_with<O: Options>(input: &str) -> Result<String>Expand description
minify under an explicit policy.
There is one minified layout, so the write settings have nothing to say
here: PRETTY and INDENT are not
read, and minify_with::<Pretty> still minifies. The one setting that
applies is ALLOW_COMMENTS, which decides
whether // and /* */ are whitespace. They are dropped like any other
whitespace, a comment being no part of what a writer can emit. With the
setting on, a slash that begins no comment is refused rather than guessed
at; with it off, a slash is an ordinary byte and goes through.
use structio::{AllowComments, json::minify_with};
let out = minify_with::<AllowComments>("[1, /* two */ 2]").unwrap();
assert_eq!(out, "[1,2]");