gecko-dev/third_party/rust/generic-array
David Teller e42e7a416c Bug 1497446 - mach rust vendor r=Yoric
Summary: The previous two changesets bump up a few dependencies. This is the companion mach rust vendor.

Test Plan: It builds.

Reviewers: ted

Tags: #secure-revision

Bug #: 1497446

--HG--
extra : amend_source : 6eeef28181e1e72891e1f3ad1d67b70cdf926e21
extra : histedit_source : e6af1b38e2272656c543f6c4f9778e80e6c75fd9
2018-10-10 16:50:30 +02:00
..
src Bug 1497446 - mach rust vendor r=Yoric 2018-10-10 16:50:30 +02:00
tests Bug 1497446 - mach rust vendor r=Yoric 2018-10-10 16:50:30 +02:00
.cargo-checksum.json Bug 1497446 - mach rust vendor r=Yoric 2018-10-10 16:50:30 +02:00
.travis.yml Bug 1497446 - mach rust vendor r=Yoric 2018-10-10 16:50:30 +02:00
Cargo.toml Bug 1497446 - mach rust vendor r=Yoric 2018-10-10 16:50:30 +02:00
LICENSE Bug 1497446 - mach rust vendor r=Yoric 2018-10-10 16:50:30 +02:00
README.md Bug 1497446 - mach rust vendor r=Yoric 2018-10-10 16:50:30 +02:00
rustfmt.toml Bug 1497446 - mach rust vendor r=Yoric 2018-10-10 16:50:30 +02:00

Crates.io Build Status

generic-array

This crate implements generic array types for Rust.

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<N> {
	data: [i32; N]
}

generic-array defines a new trait ArrayLength<T> and a struct GenericArray<T, N: ArrayLength<T>>, which let the above be implemented as:

struct Foo<N: ArrayLength<i32>> {
	data: GenericArray<i32, N>
}

To actually define a type implementing ArrayLength, you can use unsigned integer types defined in typenum crate - for example, GenericArray<T, U5> would work almost like [T; 5] :)

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);