Compost
Overview
This library exposes decompose!, a macro to decompose tuples into tuples
containing a subset of their values.
use decompose;
// Pack all your context into a tuple...
let mut cx = ;
// And cal your target function!
consumer;
// Define functions taking tuples of context...
See decompose!'s documentation for more details on the precise semantics and
limitations of the macro.
Features
Yes, this library...
- Supports reborrowing (i.e.
decompose!does not consume its input. Once you're done with the borrow, you can reuse the original tuple). - Produces (admittedly pretty ugly) errors at compile time if the tuple cannot be decomposed.
- Supports borrowing mutable, immutable, and smart-pointer wrapped (so long as they implement
Deref) components. - Supports borrowing from nested tuple trees, allowing you to borrow from an arbitrary number of components simultaneously and to quickly merge multiple context tuples by packing them into a single tuple.
- Supports borrowing generic elements without failing spuriously on monomorphization.
- Relies on type inference rather than
TypeId, allowing the macro to operate on non-'statictypes. - Supports
no_stdenvironments and does not rely on unsafe code. - Has zero runtime dependencies.