Debian Codegraph @

.cargo/vendor/cbindgen/tests/rust/const_generics_thru.rs

raw
1 // Propagating const arguments through generics that use generics.
2
3 #[repr(C)]
4 pub struct Inner<const N: usize> {
5 pub bytes: [u8; N],
6 }
7
8 #[repr(C)]
9 pub struct Outer<const N: usize> {
10 pub inner: Inner<N>, // don't declare two different structs named `Inner_N`
11 }
12
13 #[no_mangle]
14 pub extern "C" fn one() -> Outer<1> {
15 Outer { inner: Inner { bytes: [0] } }
16 }
17
18 #[no_mangle]
19 pub extern "C" fn two() -> Outer<2> {
20 Outer { inner: Inner { bytes: [0, 0] } }
21 }
22