ati 0.2.0

Introduces the `At` trait, which allows collections to be indexed by `u|i{8,16,32,64,128}` and `isize`. Supports Python-like negative index, where -1 is last element.
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented3 out of 3 items with examples
  • Size
  • Source code size: 5.33 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.31 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • KlasafGeijerstam/ati
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • KlasafGeijerstam

Ati, ergonomic indexing of Vec

The ati crate introduces the At trait, and implements it for Vec, VecDeque, [T; L] and LinkedList. The At trait adds a at and at_mut method, which allows collections to be indexed by u8, u16, u32, u64, u128, as well as i8, i16, i32, i64, i128, isize.

Negative indexes allows for indexing in the reverse direction, exactly how the Javascript at function works, or Python indexing.

Examples

use ati::At;

fn main() {
    let mut v = vec![1,2,3];

    assert_eq!(1, *v.at(0u8));
    assert_eq!(3, *v.at(-1u128));

    *v.at_mut(-1) = 5;

    assert_eq!(&[1, 2, 5], &v[..]);
}