gnaw

Lib.rs Crates.io Docs.rs

Rust 1.40.0 Build Status Crates.io - License

GitHub open issues open pull requests crev reviews

With this crate, you can conveniently chip pieces off a [slice] or [str] to use elsewhere.

Installation

Please use cargo-edit to always add the latest version of this library:

cmd cargo add gnaw

Example

```rust use gnaw::{Drain as _, Pop as _, Unshift as _};

let mut text = "abcdefg";

asserteq!(text.unshift(), Some('a')); asserteq!(text.pop(), Some('g'));

let mut drain = text.drain(); asserteq!(drain.next(), Some('b')); asserteq!(drain.next(), Some('c')); asserteq!(drain.nextback(), Some('f')); asserteq!(drain.nextback(), Some('e')); drop(drain);

//TODO: Why isn't the mutable borrow released here? //assert_eq!(text, "d"); ```

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Code of Conduct

Changelog

Versioning

gnaw strictly follows Semantic Versioning 2.0.0 with the following exceptions:

This includes the Rust version requirement specified above.
Earlier Rust versions may be compatible, but this can change with minor or patch releases.

Which versions are affected by features and patches can be determined from the respective headings in CHANGELOG.md.