caco 0.5.33

library for dealing with doom [et al] wad files
Documentation
use crate::agnostic::{ClumpMut, Entity, phantoms::PhantomDirectory};

/// Either a [`Clump`](crate::agnostic::Clump) or a subdirectory, and allowing mutable borrowing. Mutable version of [`Entity`].
pub trait EntityMut<C: ClumpMut, D>: Entity<C, D> {
    /// Gives [`Some`] with a mutable borrow of the underlying clump if the entity is a clump, otherwise gives [`None`]
    fn take_clump_mut(&mut self) -> Option<&mut C>;

    /// Gives [`Some`] with a mutable borrow of the underlying dir if the entity is a dir, otherwise gives [`None`]
    fn take_dir_mut(&mut self) -> Option<&mut D>;
}

impl<C: ClumpMut> EntityMut<C, PhantomDirectory> for C {
    fn take_clump_mut(&mut self) -> Option<&mut C> {
        Some(self)
    }

    fn take_dir_mut(&mut self) -> Option<&mut PhantomDirectory> {
        None::<&mut PhantomDirectory>
    }
}