From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- third_party/rust/generic-array/README.md | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 third_party/rust/generic-array/README.md (limited to 'third_party/rust/generic-array/README.md') diff --git a/third_party/rust/generic-array/README.md b/third_party/rust/generic-array/README.md new file mode 100644 index 0000000000..cf54f40550 --- /dev/null +++ b/third_party/rust/generic-array/README.md @@ -0,0 +1,62 @@ +[![Crates.io](https://img.shields.io/crates/v/generic-array.svg)](https://crates.io/crates/generic-array) +[![Build Status](https://travis-ci.org/fizyk20/generic-array.svg?branch=master)](https://travis-ci.org/fizyk20/generic-array) +# 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](http://fizyk20.github.io/generic-array/generic_array/) + +## 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: + +```rust +struct Foo { + data: [i32; N] +} +``` + +**generic-array** defines a new trait `ArrayLength` and a struct `GenericArray>`, which let the above be implemented as: + +```rust +struct Foo> { + data: GenericArray +} +``` + +The `ArrayLength` trait is implemented by default for [unsigned integer types](http://fizyk20.github.io/generic-array/typenum/uint/index.html) from [typenum](http://fizyk20.github.io/generic-array/typenum/index.html) crate: + +```rust +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]`: + +```rust +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: + +```rust +let array = arr![u32; 1, 2, 3]; +assert_eq!(array[2], 3); +``` -- cgit v1.2.3