crange 0.1.0

Provides types and functions to access a constant number of elements from a slice
Documentation
  • Coverage
  • 0%
    0 out of 6 items documented0 out of 4 items with examples
  • Size
  • Source code size: 17.74 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.4 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s 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
  • ShoaibMSyed

CRange

Provides types and functions to access a constant number of elements from a slice.

Examples

Indexing

use crange::Range;

let four_elements = [0, 1, 2, 3, 4, 5][Range::<4>];
assert_eq!([0, 1, 2, 3], four_elements);

let type_inference: [_; 2] = [0, 1, 2][Range];
assert_eq!([0, 1], type_inference);

let offset = [0, 1, 2, 3, 4, 5][1..][Range::<2>];
assert_eq!([1, 2], offset);

let mut mutable = [0, 1, 2, 3];
mutable[Range::<2>] = [1, 0];
assert_eq!([1, 0, 2, 3], mutable);

RangeGet trait

use crange::RangeGet;

let elements = [1, 2, 3, 4, 5];
let two = elements.get_range::<2>();
assert_eq!(Some(&[1, 2]), two);

let none = elements.get_range_mut::<6>();
assert_eq!(None, none);

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.