Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/bench-api/src/unsafe_send_sync.rs
1692 views
1
#[derive(Clone, Copy)]
2
pub struct UnsafeSendSync<T>(T);
3
4
impl<T> UnsafeSendSync<T> {
5
/// Create a new `UnsafeSendSync` wrapper around the given value.
6
///
7
/// The result is a type that is `Send` and `Sync` regardless of whether `T:
8
/// Send + Sync`, so this constructor is unsafe.
9
pub unsafe fn new(val: T) -> Self {
10
UnsafeSendSync(val)
11
}
12
13
pub fn get(&self) -> &T {
14
&self.0
15
}
16
}
17
18
unsafe impl<T> Send for UnsafeSendSync<T> {}
19
unsafe impl<T> Sync for UnsafeSendSync<T> {}
20
21