[go: up one dir, main page]

ghost 0.1.11

Define your own PhantomData
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use ghost::phantom;

#[phantom]
struct MyPhantom<T: ?Sized>;

fn require_send<T: Send>() {}
fn require_sync<T: Sync>() {}

fn main() {
    // ok
    require_send::<MyPhantom<u8>>();
    require_sync::<MyPhantom<u8>>();

    // not ok
    require_send::<MyPhantom<*const u8>>();
    require_sync::<MyPhantom<*const u8>>();
}