https://github.com/tamschi/lazy-transform-str
Lazy-copying lazy-allocated scanning str transformations
https://github.com/tamschi/lazy-transform-str
rust text-processing
Last synced: 3 months ago
JSON representation
Lazy-copying lazy-allocated scanning str transformations
- Host: GitHub
- URL: https://github.com/tamschi/lazy-transform-str
- Owner: Tamschi
- License: other
- Created: 2020-07-14T12:08:37.000Z (almost 5 years ago)
- Default Branch: develop
- Last Pushed: 2023-01-05T21:01:11.000Z (over 2 years ago)
- Last Synced: 2025-01-28T05:23:31.906Z (4 months ago)
- Topics: rust, text-processing
- Language: Rust
- Homepage: https://lib.rs/crates/lazy-transform-str
- Size: 55.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# lazy-transform-str
[](https://lib.rs/crates/lazy-transform-str)
[](https://crates.io/crates/lazy-transform-str)
[](https://docs.rs/crates/lazy-transform-str)
[](https://github.com/Tamschi/lazy-transform-str/actions?query=workflow%3ACI+branch%3Adevelop)
[](https://github.com/Tamschi/lazy-transform-str)
[](https://github.com/Tamschi/lazy-transform-str/issues)
[](https://github.com/Tamschi/lazy-transform-str/pulls)
[](https://web.crev.dev/rust-reviews/crate/lazy-transform-str/)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](https://crates.io/crates/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 _,
lazy_transform_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(…) -> … */ )
}assert_eq!(double_a("abc"), Cow::Owned(String::from("aabc")));
assert_eq!(double_a("bcd"), Cow::Borrowed("bcd"));
```## License
Licensed under either of
* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or )
* MIT license
([LICENSE-MIT](LICENSE-MIT) or )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](CODE_OF_CONDUCT.md)
## [Changelog](CHANGELOG.md)
## Versioning
`lazy-transform-str` strictly follows [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html) with the following exceptions:
* The minor version will not reset to 0 on major version changes (except for v1).
Consider it the global feature level.
* The patch version will not reset to 0 on major or minor version changes (except for v0.1 and v1).
Consider it the global patch level.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](CHANGELOG.md).