File: test.rs

package info (click to toggle)
rust-foreign-types 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, forky, sid, trixie
  • size: 112 kB
  • sloc: makefile: 4
file content (22 lines) | stat: -rw-r--r-- 521 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use foreign_types::foreign_type;

mod foo_sys {
    pub enum FOO {}

    pub unsafe extern "C" fn foo_drop(_: *mut FOO) {}
    pub unsafe extern "C" fn foo_clone(ptr: *mut FOO) -> *mut FOO { ptr }
}

foreign_type! {
    pub unsafe type Foo<'a, T>: Sync + Send {
        type CType = foo_sys::FOO;
        type PhantomData = &'a T;
        fn drop = foo_sys::foo_drop;
        fn clone = foo_sys::foo_clone;
    }

    pub unsafe type Foo2 {
        type CType = foo_sys::FOO;
        fn drop = foo_sys::foo_drop;
    }
}