use veil::Redactable;
#[derive(Redactable, Debug)] #[redact(with = 'X', partial)] struct EmailAddress(String);
impl std::fmt::Display for EmailAddress {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}
fn main() {
let email = EmailAddress("john.doe@prima.it".to_string());
assert_eq!(format!("{:?}", email), "EmailAddress(\"john.doe@prima.it\")");
assert_eq!(format!("{}", email), "john.doe@prima.it");
assert_eq!(email.redact(), "johX.XXX@XXXXa.it");
let mut buffer = String::new();
email.redact_into(&mut buffer).unwrap();
assert_eq!(buffer, "johX.XXX@XXXXa.it");
}