diff --git a/src/model/idtypes.rs b/src/model/idtypes.rs index 870e2029..12221706 100644 --- a/src/model/idtypes.rs +++ b/src/model/idtypes.rs @@ -86,15 +86,15 @@ pub struct IdBuf { impl AsRef> for IdBuf { fn as_ref(&self) -> &Id { - // Safe, b/c of the same T between types, IdBuf can't be constructed from invalid id, and Id is just a wrapped str with ZST type tag + // Safe, b/c of the same T between types, IdBuf can't be constructed + // from invalid id, and Id is just a wrapped str with ZST type tag unsafe { &*(&*self.id as *const str as *const Id) } } } impl Borrow> for IdBuf { fn borrow(&self) -> &Id { - // Safe, b/c of the same T between types, IdBuf can't be constructed from invalid id, and Id is just a wrapped str with ZST type tag - unsafe { &*(&*self.id as *const str as *const Id) } + self.as_ref() } }