mutslices 0.1.0

Provides the ability to create many mutable slices of a vector.
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented4 out of 5 items with examples
  • Size
  • Source code size: 19.55 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.48 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • pic16f877ccs/mutslices
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • pic16f877ccs

Mutslices

This crate provides the ability to create many mutable slices of a vector. Slicers are created from an array of ranges.

Exsamples

use mutslices::MutSlice;

let vec = Vec::from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
let mut mut_slice = MutSlice::vec_into(vec);
let ranges = [(0, 5), (5, 10), (10, 15)];
let [one, two, three] = &mut*mut_slice.slices_mut(&ranges) else { panic!(); };

two.swap(2, 3);
one.iter_mut().for_each(|elem| *elem = *elem * 3);
one[0] = 77;
two[1] = 78;
one.swap_with_slice(two);
two.swap_with_slice(three);
three.swap_with_slice(one);
let vec_from_slice = mut_slice.into_vec();
assert_eq!(vec_from_slice, vec![77, 6, 9, 12, 15, 11, 12, 13, 14, 15, 6, 78, 9, 8, 10]);