Mark brand types as repr(transparent) to try to ensure safety.
This commit is contained in:
@@ -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 {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user