A trait for types that are an array. An "array", for our purposes, has the following properties: Owns some number of elements. The element type can be generic, but must implement [`Default`]. The capacity is fixed at compile time, based on the implementing type. You can get a shared or mutable slice to the elements. You are generally **not** expected to need to implement this yourself. It is alr
| 14 | /// Just a reminder: this trait is 100% safe, which means that `unsafe` code |
| 15 | /// **must not** rely on an instance of this trait being correct. |
| 16 | pub trait Array { |
| 17 | /// The type of the items in the thing. |
| 18 | type Item: Default; |
| 19 | |
| 20 | /// The number of slots in the thing. |
| 21 | const CAPACITY: usize; |
| 22 | |
| 23 | /// Gives a shared slice over the whole thing. |
| 24 | /// |
| 25 | /// A correct implementation will return a slice with a length equal to the |
| 26 | /// `CAPACITY` value. |
| 27 | fn as_slice(&self) -> &[Self::Item]; |
| 28 | |
| 29 | /// Gives a unique slice over the whole thing. |
| 30 | /// |
| 31 | /// A correct implementation will return a slice with a length equal to the |
| 32 | /// `CAPACITY` value. |
| 33 | fn as_slice_mut(&mut self) -> &mut [Self::Item]; |
| 34 | |
| 35 | /// Create a default-initialized instance of ourself, similar to the |
| 36 | /// [`Default`] trait, but implemented for the same range of sizes as |
| 37 | /// [`Array`]. |
| 38 | fn default() -> Self; |
| 39 | } |
| 40 | |
| 41 | mod const_generic_impl; |
| 42 |
nothing calls this directly
no outgoing calls
no test coverage detected