Expand description
Wrapper types to unsafely make any type Send and/or Sync.
use ::core::{
cell::UnsafeCell,
ptr,
};
use ::make_send_sync::{
UnsafeSendSync,
UnsafeSync,
};
// A type that is not Send or Sync
let not_thread_safe: *const u8 = ptr::dangling();
let wrapped: UnsafeSendSync<*const u8> = unsafe { UnsafeSendSync::new(not_thread_safe) };
fn assert_send_sync<T: Send + Sync>(_: T) {}
// `wrapper` is Send + Sync, even though `not_thread_safe` is not.
assert_send_sync(wrapped);
// Look! SyncUnsafeCell on stable!
static MY_CELL: UnsafeSync<UnsafeCell<u8>> = unsafe { UnsafeSync::new(UnsafeCell::new(0)) };Structsยง
- Unsafe
Send - A wrapper that unsafely makes
TSendwithout requiring it forT. - Unsafe
Send Sync - A wrapper that unsafely makes
TSend+Syncwithout requiring it forT. - Unsafe
Sync - A wrapper that unsafely makes
TSyncwithout requiring it forT.