4 releases
0.1.3 | Oct 12, 2024 |
---|---|
0.1.2 | Oct 9, 2024 |
0.1.1 | Oct 8, 2024 |
0.1.0 | Oct 6, 2024 |
#179 in Memory management
39 downloads per month
8KB
105 lines
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) { }