try specialization
This commit is contained in:
1 parent
1126c1d329
commit
4ac6aed482
2 files changed
+45
-1
No files matched your search
@@ -12,7 +12,7 @@ use std::{
|
|||||||
sync::{atomic::AtomicU32, Arc},
|
sync::{atomic::AtomicU32, Arc},
|
||||||
};
|
};
|
||||||
|
|
||||||
use bumpalo::Bump;
|
mod testing;
|
||||||
|
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn testing() {
|
||||||
|
let testing1 = Testing::<_, false>::new(&() as *const _);
|
||||||
|
// std::thread::spawn(move || testing1);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Testing<T, const SYNC: bool> {
|
||||||
|
ptr: *mut (),
|
||||||
|
phantom: PhantomData<T>,
|
||||||
|
}
|
||||||
|
|
||||||
|
trait CreateNew<T> {
|
||||||
|
fn new(data: T) -> Testing<T, true> {
|
||||||
|
Testing {
|
||||||
|
ptr: &mut (),
|
||||||
|
phantom: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> CreateNew<T> for Testing<T, false> {
|
||||||
|
fn new(data: T) -> Testing<T, true> {
|
||||||
|
Testing {
|
||||||
|
ptr: &mut (),
|
||||||
|
phantom: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Sync + Send + 'static> Testing<T, true> {
|
||||||
|
pub fn new(data: T) -> Self {
|
||||||
|
Testing {
|
||||||
|
ptr: &mut (),
|
||||||
|
phantom: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: 'static> Testing<T, false> {}
|
||||||
|
|
||||||
|
unsafe impl<T: Send + Sync + 'static> Send for Testing<T, true> {}
|
||||||
|
unsafe impl<T: Send + Sync + 'static> Sync for Testing<T, true> {}
|
||||||
Reference in new issue
Block a user