Eso - type-level building block for making Cow-like containers
This library provids the Eso struct, a versatile building block for making
newtypes that may own or reference their contents.
How to use
Add to your Cargo.toml like:
[]
= "0.0.0"
Example
Here is how to make a basic Cow-like type:
use t;
;
Details
Eso is very flexible, because it is meant as a building block for library
authors who will restrict its flexibility to make sense for their respective
use cases:
-
The
Esotype itself can represent a choice out of any subset of- a borrowed reference
- a static or shared reference
- an owned value
Which of these variants exist in the
Esotype depends on the type parameters and can vary between usages in the client code. -
Esogeneralizes references and ownership.For example, you can make a
Cow-like type that stores a custom type instead of a normal reference, so you could make a copy-on-writeOwningRef
The price for this flexibility is ergonomics.
When using eso the types can get rather long and the where-clauses in the
library are rather unwieldy.
To Do
- More API docs
- More tests
- More examples