Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/generic-array/README.md # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / generic-array / README.md` 62 lines ยท 1777 bytes Raw Blame History Source Crates.io Build Status # generic-array This crate implements generic array types for Rust. Requires minumum Rust version of 1.36.0, or 1.41.0 for `From<[T; N]>` implementations Documentation ## Usage The Rust arrays `[T; N]` are problematic in that they can't be used generically with respect to `N`, so for example this won't work: ``` struct Foo { data: [i32; N] } ``` generic-array defines a new trait `ArrayLength` and a struct `GenericArray>`, which let the above be implemented as: ``` struct Foo> { data: GenericArray } ``` The `ArrayLength` trait is implemented by default for unsigned integer types from typenum crate: ``` use generic_array::typenum::U5; struct Foo> { data: GenericArray } fn main() { let foo = Foo::{data: GenericArray::default()}; } ``` For example, `GenericArray` would work almost like `[T; 5]`: ``` use generic_array::typenum::U5; struct Foo> { data: GenericArray } fn main() { let foo = Foo::{data: GenericArray::default()}; } ``` In version 0.1.1 an `arr!` macro was introduced, allowing for creation of arrays as shown below: ``` let array = arr![u32; 1, 2, 3]; assert_eq!(array[2], 3); ```