From 9ee7882b1f94de7c43ce62574d2021b8bb788d55 Mon Sep 17 00:00:00 2001 From: Stu Black Date: Wed, 22 Jan 2025 14:13:58 -0500 Subject: [PATCH] Mark brand types as `repr(transparent)` to try to ensure safety. --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 1c2bcdc..fe12ef2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,6 +38,7 @@ pub trait BrandState: Copy + fmt::Debug + Eq + Hash + Ord + sealed::Sealed {} /// Zero-sized marker type that indicates a graph or graph handle is in the open /// state. See [`Graph::open`]. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] +#[repr(transparent)] pub struct Open<'id>(PhantomData<*mut &'id ()>); impl<'id> BrandState for Open<'id> {} unsafe impl<'id> Send for Open<'id> {} @@ -51,6 +52,7 @@ unsafe impl<'id> Sync for Open<'id> {} /// around without having to stay within the bounds of a single call to /// `Graph::open`. See [`Graph::open`] (and [`Graph::closed`]). #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)] +#[repr(transparent)] pub struct Closed; impl BrandState for Closed {}