A more compact, user friendly clone-on-write smart pointer.
```rust use std::path::Path; use dairy::Cow;
let borrowed: Cow
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:
str
, [T]
, OsStr
, CStr
and Path
types are supported.OsStr
and Path
are only supported on Unix.u16::MAX
which is
not sufficient for all use cases.Add the following to your Cargo manifest.
toml
[dependencies]
dairy = { version = "0.1", features = ["unix"] }
Some implementation details taken from the excellent beef crate.
Licensed under either of
at your option.