parr

Crates.ioparr
lib.rsparr
version0.1.3
created_at2024-10-06 20:08:59.666244+00
updated_at2024-10-12 16:19:49.827392+00
descriptionA C-like unknown-length array type.
homepage
repositoryhttps://github.com/andofwinds/parr
max_upload_size
id1399363
size22,194
Andea (andofwinds)

documentation

README

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) { }
Commit count: 10

cargo fmt