nextest_runner/config/
track_default.rsuse serde::{Deserialize, Deserializer};
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub(crate) struct TrackDefault<T> {
pub value: T,
pub is_deserialized: bool,
}
impl<T> TrackDefault<T> {
pub fn with_default_value(value: T) -> Self {
Self {
value,
is_deserialized: false,
}
}
pub fn with_deserialized_value(value: T) -> Self {
Self {
value,
is_deserialized: true,
}
}
}
impl<'de, T> Deserialize<'de> for TrackDefault<T>
where
T: Deserialize<'de>,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let value = Self::with_deserialized_value(T::deserialize(deserializer)?);
Ok(value)
}
}