coproduct 0.4.1

Generic coproduct type with minimal memory footprint
Documentation
/// Trait for properly deallocating Unions that are not Copy.
///
/// Unlike the other Indexed* traits, this one is exported because there is no
/// way to avoid mentioning it. For example to require IndexedClone it suffices
/// to require that `Coproduct<T>` is [Clone].
pub trait IndexedDrop {
    /// # Safety
    /// The argument `i` must be the index of the active variant
    /// of the Union.
    unsafe fn idrop(&mut self, i: u32);
}

/// This trait is implemented for Unions where variant I has type X.
pub trait UnionAt<I, X> {
    /// Create a union that contains the given value.
    fn inject(x: X) -> Self;

    /// Convert a union to the contained type.
    /// # Safety
    /// If the active variant of the coproduct is not at index I,
    /// calling this method is undefined behaviour.
    unsafe fn take(self) -> X;

    /// The coproduct minus its Ith variant
    type Pruned;
}