arraysetcell 0.1.0

A fixed-capacity, vector-like array with interior mutability and no ordering guarantees
Documentation
  • Coverage
  • 88.89%
    8 out of 9 items documented1 out of 5 items with examples
  • Size
  • Source code size: 52.22 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 803.93 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • sunsided/arraysetcell
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • sunsided

ArraySetCell

Crates.io Crates.io GitHub Workflow Status Safety Dance docs.rs codecov

A fixed-capacity, vector-like array with interior mutability and no ordering guarantees.

use std::cell::Cell;
use arraysetcell::ArraySetCell;

fn it_works() {
    let mut array = ArraySetCell::<u32, 3>::from([Some(1), None, Some(3)]);
    assert_eq!(array.capacity(), 3);
    assert_eq!(array.len(), 2);

    array.push(10);
    assert_eq!(array.len(), 3);

    array.retain(|x| *x < 10);
    assert_eq!(array.len(), 2);

    let result = array.filter_mut(|x| if *x > 2 { Some(*x) } else { None });
    assert_eq!(result, Some(3));

    let mut iter = array.into_iter();
    assert_eq!(iter.size_hint(), (2, Some(2)));
    assert_eq!(iter.next(), Some(1));
    assert_eq!(iter.next(), Some(3));
    assert_eq!(iter.next(), None);
}