alloc-no-stdlib 2.0.4

A dynamic allocator that may be used with or without the stdlib. This allows a package with nostd to allocate memory dynamically and be used either with a custom allocator, items on the stack, or by a package that wishes to simply use Box<>. It also provides options to use calloc or a mutable global variable for pre-zeroed memory
Documentation
use alloc_no_stdlib;
use core;
use alloc_no_stdlib::{SliceWrapper, SliceWrapperMut};

pub struct Rebox<T> {
   b : Box<[T]>,
}

impl<T> core::default::Default for Rebox<T> {
    fn default() -> Self {
       let v : Vec<T> = Vec::new();
       let b = v.into_boxed_slice();
       return Rebox::<T>{b : b};
    }
}
define_index_ops_mut!(T, Rebox<T>);

impl<T> alloc_no_stdlib::SliceWrapper<T> for Rebox<T> {
    fn slice(&self) -> & [T] {
       return &*self.b
    }
}

impl<T> alloc_no_stdlib::SliceWrapperMut<T> for Rebox<T> {
    fn slice_mut(&mut self) -> &mut [T] {
       return &mut*self.b
    }
}

pub struct HeapAllocator<T : core::clone::Clone>{
   pub default_value : T,
}

impl<T : core::clone::Clone> alloc_no_stdlib::Allocator<T> for HeapAllocator<T> {
   type AllocatedMemory = Rebox<T>;
   fn alloc_cell(self : &mut HeapAllocator<T>, len : usize) -> Rebox<T> {

       let v : Vec<T> = vec![self.default_value.clone();len];
       let b = v.into_boxed_slice();
       return Rebox::<T>{b : b};
   }
   fn free_cell(self : &mut HeapAllocator<T>, _data : Rebox<T>) {

   }
}