Function const_generic_show

Source
pub fn const_generic_show()
Expand description

ยงconst generic

#![feature(min_const_generics)]
#![feature(const_in_array_repeat_expressions)]

use core::mem::MaybeUninit;

#[derive(Debug)]
pub struct ArrayVec<T, const N: usize> {
    items: [MaybeUninit<T>; N],
    length: usize,
}

impl<T, const N: usize> ArrayVec<T,  {N} > {
    pub const fn new() -> ArrayVec<T, {N} > {
        ArrayVec {
            items: [MaybeUninit::uninit(); N],
            length: 0,
        }
    }

    #[inline]
    pub const fn len(&self) -> usize { self.length }

    #[inline]
    pub const fn is_empty(&self) -> bool { self.len() == 0 }

    #[inline]
    pub const fn capacity(&self) -> usize { N }

    #[inline]
    pub const fn is_full(&self) -> bool { self.len() >= self.capacity() }

}

impl<T, const N: usize> Drop for ArrayVec<T, { N }> {
    #[inline]
    fn drop(&mut self) {
        // Makes sure the destructors for all items are run.
        // self.clear();
    }
}


fn main(){
    // let mut vector = ArrayVec::new();
    // println!("{}, {}", vector.len(), vector.capacity());
    // println!("{:?}", vector);
}