pub struct Config {
pub width_limit: usize,
pub indent_width: usize,
}
Expand description
Config
uration options for JSON formatting with format_with_config
.
Fields§
§width_limit: usize
Maximum line length, in characters. Defaults to 100.
§Example
use goldilocks_json_fmt::{Config, format_with_config};
// Add more indentation (4 spaces, not the default of 2)
assert_eq!(
format_with_config(
r#"{"test/cases/87s-at-back.toml":{"comps":[{"length":32,
"string":"sHsH","avg_score":-0.45625}]}}"#,
&Config {
width_limit: 40,
..Config::default()
}
).unwrap(),
r#"{
"test/cases/87s-at-back.toml": {
"comps": [
{
"length": 32,
"string": "sHsH",
"avg_score": -0.45625
}
]
}
}"#
);
indent_width: usize
Number of spaces added for each indentation level. Defaults to 2.
§Example
use goldilocks_json_fmt::{Config, format_with_config};
// Add more indentation (4 spaces, not the default of 2)
assert_eq!(
format_with_config(
r#"{"test/cases/87s-at-back.toml":{"comps":[{"length":32,
"string":"sHsH","avg_score":-0.45625}]}}"#,
&Config {
indent_width: 4,
width_limit: 40, // Force more splitting for demo purposes
..Config::default()
}
).unwrap(),
r#"{
"test/cases/87s-at-back.toml": {
"comps": [
{
"length": 32,
"string": "sHsH",
"avg_score": -0.45625
}
]
}
}"#
);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more