caja 0.2.1

Adds the Caja struct which is basically Box<[T;n]>, but n can be not known at compile-time
Documentation
  • Coverage
  • 72.73%
    8 out of 11 items documented0 out of 9 items with examples
  • Size
  • Source code size: 45.26 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.13 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • EmanuelGCC

Caja


Caja is a simple rust library that allows for the creation of fixed sized arrays of a size unknown at compile time. It is basically Box<[T;n]> but allowing the n to be non constant value.

Example


extern crate caja;

use caja::Caja;



pub fn main() {

    // Creates a heap allocated array of size 108 with the default value 0xEE

    let caj = Caja::<u16>::new(108, 0xEE).unwrap();

    // it is also possible to use new_zeroed and new_uninitialized



    // Caja implements Display and Debug, as long as T does so too.

    println!("{}", caj);

    

    // Caja implements Index and IndexMut, so it is possible to access it as any normal array.

    println!("{}", caj[77]);



    //  And you can also access the underlying pointer inside of Caja

    println!("{:p}", caj.as_mut_ptr());

}