Butcher
An easy way to interact with Cow
ed structs and enums.
This crate proposes some simple solutions to the most common patterns I met
while working with Cow
s in Rust. It currently fixes two patterns:
destructuring and iteration related to objects wrapped in Cow
.
Destructuring
The Butcher
trait can be used when it is necessary to destruture something
wrapped in a Cow
. Below is a simple example:
use Cow;
use Butcher;
The Butcher
procedural macro can be derived for structs
and for enums.
Iteration
Here is a demonstration of how to iterate over an object wrapped in a Cow
:
use Cow;
use ;
See the documentation of CowIter
for more information.
Flattening
In some situations, the Butcher
proc macro can generate tricky fields,
such as nested Cow
. The FlattenCow
trait aims to remove such
flattening. See its documentation for more.