cow-utils 0.1.1

Copy-on-write string utilities for Rust
Documentation

Copy-on-write string utils for Rust

Some str methods perform destructive transformations and so they allocate, copy into and return a new String even when no modification is necessary.

This crate provides a helper trait CowUtils with drop-in variants of such methods, which behave in the same way, but avoid extra copies and allocations when no modification is necessary.

For now it's only implemented for &str and returns std::borrow::Cow<str>, but in the future might be extended to other types where even more efficient handling is possible (e.g. in-place modifications on mutable strings).

Usage

First, you need to import CowUtils into the scope:

use cow_utils::CowUtils;

Then you can start invoking following .cow_-prefixed methods on strings instead of the regular ones:

Check out the docs for detailed examples.

License

MIT