.cargo/vendor/cbindgen/tests/rust/const_generics_arrayvec.rs
raw| 1 | #[repr(C)] |
| 2 | pub struct ArrayVec<T, const CAP: usize> { |
| 3 | // the `len` first elements of the array are initialized |
| 4 | xs: [T; CAP], |
| 5 | len: u32, |
| 6 | } |
| 7 | |
| 8 | #[no_mangle] |
| 9 | pub unsafe extern "C" fn push(v: *mut ArrayVec<*mut u8, 100>, elem: *mut u8) -> i32 { |
| 10 | if (*v).len < 100 { |
| 11 | (*v).xs[(*v).len] = elem; |
| 12 | (*v).len += 1; |
| 13 | 1 |
| 14 | } else { |
| 15 | 0 |
| 16 | } |
| 17 | } |