mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-27 06:30:20 +00:00
try specialization
This commit is contained in:
parent
1126c1d329
commit
4ac6aed482
2 changed files with 45 additions and 1 deletions
|
@ -12,7 +12,7 @@ use std::{
|
||||||
sync::{atomic::AtomicU32, Arc},
|
sync::{atomic::AtomicU32, Arc},
|
||||||
};
|
};
|
||||||
|
|
||||||
use bumpalo::Bump;
|
mod testing;
|
||||||
|
|
||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
|
|
44
packages/generational-box/src/testing.rs
Normal file
44
packages/generational-box/src/testing.rs
Normal file
|
@ -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> {}
|
Loading…
Reference in a new issue