Skip to content

Commit

Permalink
Make StackToken zero size
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Oct 18, 2022
1 parent 512ee60 commit 6ecd8df
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ mod semisticky;
mod sticky;
mod thread_id;

use std::marker::PhantomData;

pub use crate::errors::InvalidThreadAccess;
pub use crate::fragile::Fragile;
pub use crate::semisticky::SemiSticky;
Expand All @@ -112,15 +114,15 @@ pub use crate::sticky::Sticky;
///
/// For more information about how these work see the documentation of
/// [`stack_token!`] which is the only way to create this token.
pub struct StackToken(*const ());
pub struct StackToken(PhantomData<*const ()>);

impl StackToken {
/// Stack tokens must only be created on the stack.
#[doc(hidden)]
pub unsafe fn __private_new() -> StackToken {
// we place a const pointer in there to get a type
// that is neither Send nor Sync.
StackToken(std::ptr::null())
StackToken(PhantomData)
}
}

Expand Down

0 comments on commit 6ecd8df

Please sign in to comment.