use crate::rawvalue::RawValue;
pub trait PropertyValue: Sized {
const MAYBE_UNSET: bool;
type Err;
fn parse(value: &RawValue) -> Result<Self, Self::Err>;
}
pub trait PropertyKey {
fn key() -> &'static str;
}
#[cfg(test)]
pub fn test_reparse<T, E: std::fmt::Debug>(initial: T)
where
T: Clone + PropertyValue<Err = E> + Into<RawValue> + std::fmt::Debug + PartialEq,
{
let written: RawValue = initial.clone().into();
let result = T::parse(&written).expect("reparse errored");
assert!(
!result.ne(&initial),
"reparsed value is unequal to original; expected `{:?}`, got `{:?}`",
initial,
result
)
}