Skip to main content

impl_json_display

Macro impl_json_display 

Source
macro_rules! impl_json_display {
    ($($ty:ty),+ $(,)?) => { ... };
}
Expand description

Implements Display as compact JSON for one or more Serialize types.

Expands to an impl std::fmt::Display per type that delegates to write_json.

use optionstratlib_core::impl_json_display;
use serde::Serialize;

#[derive(Serialize)]
struct Fill {
    qty: u32,
}
impl_json_display!(Fill);

assert_eq!(Fill { qty: 3 }.to_string(), r#"{"qty":3}"#);