2 unstable releases
0.2.0 | Jan 15, 2025 |
---|---|
0.1.0 | Jan 11, 2025 |
#1050 in Rust patterns
249 downloads per month
36KB
492 lines
str-chunks
About
implements char-wise chunked iteration of str
the methods str_chunks
, str_chunks_exact
, str_rchunks
, and str_rchunks_exact
behave like the similarly named methods on slice,
but return string slices that are chunk_size
chars long.
take note: these slices are not necessarily chunk_size
bytes long. chunk.len() != chunk_size
import ImplStrChunks
to get methods on str
Usage
Add to your Cargo.toml:
[dependencies]
str-chunks = "0.1.1"
See docs.rs for examples.
or just copy src/str_chunks.rs into your own project. im not your mom. dont forget to remove the #![no_std]
lib.rs
:
str chunks
implements char-wise chunked iteration of str
the methods str_chunks
, str_chunks_exact
, str_rchunks
, and str_rchunks_exact
behave like the similarly named methods on slice,
but return string slices that are chunk_size
chars long.
take note: these slices are not necessarily chunk_size
bytes long. chunk.len() != chunk_size
import ImplStrChunks
to get methods on &str
For DoubleEndedIterator
support, use the reversable
method.
This is not a trivial operation, and it is recommended to avoid it if possible.