https://github.com/coriolinus/iterext
Further extensions on iterators
https://github.com/coriolinus/iterext
Last synced: 18 days ago
JSON representation
Further extensions on iterators
- Host: GitHub
- URL: https://github.com/coriolinus/iterext
- Owner: coriolinus
- License: mit
- Created: 2021-02-17T20:15:42.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-23T21:04:07.000Z (over 5 years ago)
- Last Synced: 2026-01-03T01:15:21.018Z (7 months ago)
- Language: Rust
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `iterext`: A few more extension methods on iterators.
This crate is not likely to ever be published on because it's
far more appropriate to attepmt to get these extensions added to
[`itertools`](https://crates.io/crates/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:
```rust
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::();
assert_eq!(have, "fooXX");
}
```
## Provenance
Originally wrote these extensions as part of the [`textbyte`](https://github.com/coriolinus/solitaire/blob/master/src/textbyte.rs)
module for my [`solitaire`](https://github.com/coriolinus/solitaire/) implementation.