File: const_transparent.rs

package info (click to toggle)
rust-cbindgen 0.27.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,616 kB
  • sloc: ansic: 15; makefile: 11
file content (32 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#[repr(transparent)]
struct TransparentStruct { field: u8 }

impl TransparentStruct {
    pub const ASSOC_STRUCT_FOO: i64 = 1;
    pub const ASSOC_STRUCT_BAR: TransparentStruct = TransparentStruct { field: 2 };

    // TODO: Only C++ supports template constants so far.
    pub const ASSOC_STRUCT_BAZ: Wrapper<TransparentStruct> = Wrapper { field: TransparentStruct { field: 3 } };
}

#[repr(transparent)]
struct TransparentTupleStruct(u8);

#[repr(transparent)]
struct Wrapper<T> { field: T }

pub const STRUCT_FOO: TransparentStruct = TransparentStruct { field: 4 };
pub const STRUCT_BAR: TransparentTupleStruct = TransparentTupleStruct(5);

// TODO: Only C++ supports template constants so far.
pub const STRUCT_BAZ: Wrapper<TransparentStruct> = Wrapper { field: TransparentStruct { field: 6 } };

#[repr(transparent)]
struct TransparentStructWithErasedField<T> {
    field: Wrapper<T>,
}

// TODO: Only C++ supports template constants so far.
pub const COMPLEX: TransparentStructWithErasedField<TransparentStruct> = TransparentStructWithErasedField {
    field: Wrapper { field: TransparentStruct { field: 7 } }
};