I read about serde::skip_serializing_if and I would like to iplement it into my project, however I did not find a way to read the value at runtime (imagine a flag --ignore-practices
).
I tried with a static value but without success...
See example below.
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct IP {
pub name: String,
#[serde(skip_serializing_if = "read_flag_from_command_line")]
pub practices: Option<Practices>,
}
fn is_false<T>(_: T) -> bool {
let ignore = value_at_run_time;
return ignore;
}