slicetools 0.3.0

Add extra iterators to slices.
Documentation
  • Coverage
  • 90%
    9 out of 10 items documented6 out of 7 items with examples
  • Size
  • Source code size: 29.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.52 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
  • Boiethios/slicetools
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Boiethios

This crate aims to provide various tools for slices.

This crate use its own streaming iterator due to the lack of generic associated type in the language: you therefore cannot use those iterators with the for control flow. Use the while let control flow, or the macro helper, as you can see below.

Example

Cargo.toml:

[dependencies]
slicetools = "0.2.*"

main.rs:

extern crate slicetools;

use slicetools::*;

let mut v = vec![1, 2, 3, 4];
{
    let mut it = v.pairs_mut();
    
    while let Some((a, b)) = it.next() {
        if *b > *a {
            *a += 1;
        }
    }
}
assert_eq!(v, &[4, 4, 4, 4]);

Or, with the helper macro:

#[macro_use] extern crate slicetools;

use slicetools::*;

let mut v = vec![1, 2, 3, 4];

stream!( v.pairs_mut() => (a, b) in {
    if *b > *a {
        *a += 1;
    }
});
assert_eq!(v, &[4, 4, 4, 4]);

Changelog

0.3.*

  • Add 3 new extensions to take groups of items.

0.2.*

  • Use own streaming iterator instead of regular iterator that was unsafe (allowed multiple mutable borrowing on the same item).

  • Add a new streamer for doing a cartesian product between two slices.