Expand description
§The Pointer Array (PArr).
§Provides a type to make raw pointer indexable as an array, just like in C!
§Examples
§New from raw address
let arr: Parr<u8> = Parr::new(&[11_u8, 22, 33, 44] as *const _ as u64);
assert_eq!(arr[1], 22);
Same code in C:
uint8_t arr[] = {11, 22, 33, 44};
// arr[1] == 22
§Usage in structures
#[repr(C)]
struct Foo {
arr: Parr<u8>,
}
Same code in C:
struct foo {
uint8_t* arr,
};
§Usage in function arguments
extern "C" fn foo(arr: Parr<u8>) { }
Same code in C:
void foo(uint8_t* arr) { }
Structs§
- Parr
- The Pointer Array.