[][src]Trait kul_core::DerefTryMut

pub trait DerefTryMut: Deref where
    Self::Target: Sized
{ fn get_mut(this: &mut Self) -> Option<&mut Self::Target>; }

Exists to be used similarly to but differently than DerefMut so that types like Rc and its get_mut method can be used to hold Datums. DerefMut must never fail, so it can't be used. We want mutability of Datums so that we can construct lists of them using only the space of the values allocated by a Parser's DatumAllocator, since this crate is intended to be usable in no_std environments which don't provide heap allocation.

The alternative of using tree-recursion to acheive temporary stack allocation for constructing the lists without mutation is not good because the stack is too small for large lists and it could realistically be exceeded (causing a crash). While no_std environments might also have restricted limits to the amounts of Datums that could be allocated, with our approach they can control the limit and can receive an Error value under their control if the limit is exceeded (instead of a crash).

Required methods

fn get_mut(this: &mut Self) -> Option<&mut Self::Target>

Returns a mutable reference to the inner Datum if it can. Otherwise, returns None. Some implementations may never return None (e.g. for types that also implement DerefMut).

Loading content...

Implementors

impl<TT, ET, '_> DerefTryMut for DatumMutRef<'_, TT, ET>[src]

This allows basic direct mutable borrow references to be used as the Datum reference type.

Loading content...