refactor(domain): delegate OrgId Display, rename to_uuid, mark new must_use
This commit is contained in:
@@ -13,6 +13,7 @@ pub struct OrgId(Uuid);
|
|||||||
|
|
||||||
impl OrgId {
|
impl OrgId {
|
||||||
/// Generate a fresh random id.
|
/// Generate a fresh random id.
|
||||||
|
#[must_use = "generating an OrgId and discarding it is almost certainly a mistake"]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self(Uuid::new_v4())
|
Self(Uuid::new_v4())
|
||||||
}
|
}
|
||||||
@@ -22,8 +23,8 @@ impl OrgId {
|
|||||||
Self(uuid)
|
Self(uuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The underlying [`Uuid`].
|
/// Return the underlying [`Uuid`].
|
||||||
pub fn as_uuid(&self) -> Uuid {
|
pub fn to_uuid(&self) -> Uuid {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,7 +37,7 @@ impl Default for OrgId {
|
|||||||
|
|
||||||
impl fmt::Display for OrgId {
|
impl fmt::Display for OrgId {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", self.0)
|
fmt::Display::fmt(&self.0, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user