feat(domain): restore must_use message; test TermRef accessors
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@ macro_rules! id_newtype {
|
|||||||
|
|
||||||
impl $name {
|
impl $name {
|
||||||
/// Generate a fresh random id.
|
/// Generate a fresh random id.
|
||||||
#[must_use]
|
#[must_use = "generating an id and discarding it is almost certainly a mistake"]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self(uuid::Uuid::new_v4())
|
Self(uuid::Uuid::new_v4())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,3 +50,18 @@ impl TermRef {
|
|||||||
self.vocabulary_id
|
self.vocabulary_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use crate::{TermId, VocabularyId};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn term_ref_exposes_its_parts() {
|
||||||
|
let term_id = TermId::new();
|
||||||
|
let vocabulary_id = VocabularyId::new();
|
||||||
|
let r = TermRef::new(term_id, vocabulary_id);
|
||||||
|
assert_eq!(r.term_id(), term_id);
|
||||||
|
assert_eq!(r.vocabulary_id(), vocabulary_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user