Expand description
Utilities for splitting sequences with range parameters.
The TakeRange
trait provides polymorphic, easily memorizable methods
for splitting indexed sequences with a parameter given in range syntax.
use range_split::TakeRange;
let mut buf = Bytes::from("Hello, world");
let p = buf.take_range(..5);
buf.remove_range(2..);
assert_eq!(p, "Hello");
assert_eq!(buf, ", ");
is equivalent to
let mut buf = Bytes::from("Hello, world");
let p = buf.split_to(5);
buf.truncate(2);
Implementations of TakeRange
are provided for Bytes
and BytesMut
from the crate bytes
if the bytes
compile-time feature is enabled.
Modules§
- Utilities for working with ranges of collections in memory.
- Utilities for validating ranges on UTF-8 strings.
Macros§
- Asserts that the given range is valid for the given string slice.
Traits§
- Methods for splitting out part of a collection with a given range.