1 unstable release

0.1.0 Feb 23, 2021

#2926 in Rust patterns

Download history 79/week @ 2023-12-09 78/week @ 2023-12-16 4/week @ 2023-12-23 63/week @ 2023-12-30 153/week @ 2024-01-06 150/week @ 2024-01-13 71/week @ 2024-01-20 95/week @ 2024-01-27 114/week @ 2024-02-03 52/week @ 2024-02-10 73/week @ 2024-02-17 47/week @ 2024-02-24 44/week @ 2024-03-02 179/week @ 2024-03-09 168/week @ 2024-03-16 121/week @ 2024-03-23

521 downloads per month
Used in 2 crates (via num-runtime-fmt)

MIT license

8KB
151 lines

iterext: A few more extension methods on iterators.

This crate is not likely to ever be published on https://crates.io because it's far more appropriate to attepmt to get these extensions added to itertools. However, I haven't yet made the time to attempt to contribute them there.

A few quick examples from the tests should show what it's about:

use iterext::prelude::*;

#[test]
fn test_separate() {
    for (msg, expect) in &[
        ("abc", "abc"),
        ("zyx", "zyx"),
        (
            "abcdefghijklmnopqrstuvwxyz",
            "abcde fghij klmno pqrst uvwxy z",
        ),
        (
            "thequickbrownfoxjumpedoverthelazydog",
            "thequ ickbr ownfo xjump edove rthel azydo g",
        ),
        (
            "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz",
            "abcde fghij klmno pqrst uvwxy zabcd efghi jklmn opqrs tuvwx yz",
        ),
    ] {
        let got: String = msg.chars().separate(' ', 5);
        assert_eq!(&got, expect,);
    }
}

#[test]
fn test_padding_chars() {
    let have = "foo".chars().pad('X', 5).collect::<String>();
    assert_eq!(have, "fooXX");
}

Provenance

Originally wrote these extensions as part of the textbyte module for my solitaire implementation.

Dependencies

~400KB