From 6c601fae087f93814c3e5f3b460ce1781e9b3a90 Mon Sep 17 00:00:00 2001 From: adlee-was-taken Date: Sun, 19 Apr 2026 09:50:24 -0400 Subject: [PATCH] chore(core): add Default impls + FieldId uniqueness test Code review fixups: - ItemId/FieldId need impl Default delegating to ::new() to silence clippy::new_without_default - FieldId was missing the parallel uniqueness test that ItemId has Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/idfoto-core/src/ids.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/idfoto-core/src/ids.rs b/crates/idfoto-core/src/ids.rs index 9da53a0..58c403e 100644 --- a/crates/idfoto-core/src/ids.rs +++ b/crates/idfoto-core/src/ids.rs @@ -31,6 +31,10 @@ impl ItemId { pub fn as_str(&self) -> &str { &self.0 } } +impl Default for ItemId { + fn default() -> Self { Self::new() } +} + impl FieldId { pub fn new() -> Self { let mut bytes = [0u8; 8]; @@ -40,6 +44,10 @@ impl FieldId { pub fn as_str(&self) -> &str { &self.0 } } +impl Default for FieldId { + fn default() -> Self { Self::new() } +} + impl AttachmentId { pub fn from_plaintext(plaintext: &[u8]) -> Self { let digest = Sha256::digest(plaintext); @@ -74,6 +82,14 @@ mod tests { assert!(id.0.chars().all(|c| c.is_ascii_hexdigit())); } + #[test] + fn field_ids_are_unique() { + let mut seen = std::collections::HashSet::new(); + for _ in 0..10_000 { + assert!(seen.insert(FieldId::new().0)); + } + } + #[test] fn attachment_id_is_deterministic() { let plaintext = b"hello world";