[][src]Trait kul::drop::Algo1DatumRef

pub trait Algo1DatumRef: DerefTryMut where
    Self::Target: Sized
{ fn try_replace(
        this: &mut Self,
        val: Self::Target
    ) -> Result<Self::Target, Self::Target>;
fn set(this: &mut Self, val: Self::Target); }

Exists so that Datums can be moved-out of the reference types that refer to them, even when there are other weak references.

Required methods

fn try_replace(
    this: &mut Self,
    val: Self::Target
) -> Result<Self::Target, Self::Target>

Returns the inner Datum and replaces it with the given value, if possible. Otherwise, an error is returned containing the passed-in value. Some implementations might always succeed.

fn set(this: &mut Self, val: Self::Target)

Mutates the inner Datum to be the given value. This must never fail. It is only called after our try_replace function is called on the same this value and succeeded, which allows this set function to never fail.

Loading content...

Implementors

impl<TT, ET> Algo1DatumRef for DatumBox<TT, ET>[src]

This allows using the custom drop algorithm

impl<TT, ET> Algo1DatumRef for DatumRc<TT, ET>[src]

This allows using the custom drop algorithm, and it allows the algorithm to restructure tree nodes that have other weak references to them (which isn't possible with DerefTryMut::get_mut alone).

impl<TT, ET> Algo1DatumRef for DatumArc<TT, ET>[src]

This allows using the custom drop algorithm, and it allows the algorithm to restructure tree nodes that have other weak references to them (which isn't possible with DerefTryMut::get_mut alone).

Loading content...