1 use std::mem::MaybeUninit;
4 pub unsafe trait Array {
5 /// The array’s element type
8 /// The smallest index type that indexes the array.
11 fn as_ptr(&self) -> *const Self::Item;
13 fn as_mut_ptr(&mut self) -> *mut Self::Item;
15 fn capacity() -> usize;
18 pub trait Index : PartialEq + Copy {
19 fn to_usize(self) -> usize;
20 fn from(i: usize) -> Self;
23 impl Index for usize {
24 fn to_usize(self) -> usize { self }
25 fn from(val: usize) -> Self {
30 unsafe impl<T> Array for [T; 1] {
33 fn as_ptr(&self) -> *const T { self as *const _ as *const _ }
34 fn as_mut_ptr(&mut self) -> *mut T { self as *mut _ as *mut _}
35 fn capacity() -> usize { 1 }
38 impl<A: Array> Deref for ArrayVec<A> {
39 type Target = [A::Item];
41 fn deref(&self) -> &[A::Item] {
46 pub struct ArrayVec<A: Array> {
51 impl<A: Array> ArrayVec<A> {
52 pub fn new() -> ArrayVec<A> {
58 let mut buffer = ArrayVec::new();
59 let x = buffer.last().unwrap().0.clone();
60 //~^ ERROR type annotations needed
61 //~| ERROR no field `0` on type `&_`