fixed_vec

Crates.iofixed_vec
lib.rsfixed_vec
version0.1.0
sourcesrc
created_at2020-07-30 10:58:26.368266
updated_at2020-07-30 10:58:26.368266
descriptionGhosts of Departed Proofs for checking valid indices of Vec's once
homepagehttps://github.com/Torrencem/fixed_vec
repositoryhttps://github.com/Torrencem/fixed_vec
max_upload_size
id271239
size36,945
Matt Torrence (Torrencem)

documentation

https://docs.rs/fixed_vec

README

fixed_vec

Bounds check indices only once, instead of over and over if the indices will be re-used:

use fixed_vec::{name, FixedVec};

let v = vec![0u32; 10];
let v = name!(v);
let mut v = FixedVec::fix(v);

// Perform the two index checks here:
let index_a = v.check_index(...).unwrap();
let index_b = v.check_index(...).unwrap();

for _ in 0..100 {
    // These do *not* perform bounds checks!
    // At compile time, v and index_a must match
    *v.get_mut(index_a) += 5;
    *v.get_mut(index_b) += 10;
}

let v = v.unfix();

// continue using v...

See the concept post for more information.

Commit count: 13

cargo fmt