dairy
A more compact, user friendly clone-on-write smart pointer.
use Path;
use Cow;
let borrowed: = borrowed;
let owned: = owned;
Introduction
dairy::Cow is an improved version of the standard library std::borrow::Cow.
It is just 2 words wide, storing the length, capacity, and the ownership tag all
in one word. See tests/size.rs.
dairy::Cow has many more From and PartialEq implementations. Most notably
for Cow<Path> making Into<Cow<Path>> just as nice to use as Cow<str>.
Unfortunately these benefits come with some caveats:
- Only
str,[T],OsStr,CStrandPathtypes are supported. - Additionally,
OsStrandPathare only supported on Unix. - On 32-bit operating systems the maximum length is
u16::MAXwhich is not sufficient for all use cases.
Getting started
Add the following to your Cargo manifest.
[]
= { = "0.1", = ["unix"] }
Acknowledgements
Some implementation details taken from the excellent beef crate.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.