lazy-transform-str

Lib.rs Crates.io Docs.rs

Rust 1.46.0 Build Status Crates.io - License

GitHub open issues open pull requests crev reviews

Lazy-copying lazy-allocated scanning str transformations.

This is good e.g. for (un)escaping text, especially if individual strings are short.

Installation

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

cmd cargo add lazy-transform-str

Example

```rust use { cervine::Cow, gnaw::Unshift as , lazytransform_str::{Transform as _, TransformedPart}, smartstring::alias::String, };

fn double_a(str: &str) -> Cow { str.transform(|rest /: &mut &str */| { // Consume some of the input. rest is never empty here. match rest.unshift().unwrap() { 'a' => TransformedPart::Changed(String::from("aa")), _ => TransformedPart::Unchanged, } } /: impl FnMut(…) -> … */ ) }

asserteq!(doublea("abc"), Cow::Owned(String::from("aabc"))); asserteq!(doublea("bcd"), Cow::Borrowed("bcd")); ```

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

lazy-transform-str strictly follows Semantic Versioning 2.0.0 with the following exceptions:

This includes the Rust version requirement specified above.
Earlier 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.