Trait DropWith

Source
pub trait DropWith<E: Edge>: Sized {
    // Required method
    fn drop_with(self, drop_edge: impl Fn(E));

    // Provided method
    fn drop_with_manager<M: Manager<Edge = E>>(self, manager: &M) { ... }
}
Expand description

Drop functionality for containers of Edges

An edge on its own cannot be dropped: It may well be just an integer index for an array. In this case we are lacking the base pointer, or more abstractly the Manager. Most edge containers cannot store a manager reference, be it for memory consumption or lifetime restrictions. This trait provides methods to drop such a container with an externally supplied function to drop edges.

Required Methods§

Source

fn drop_with(self, drop_edge: impl Fn(E))

Drop self

Among dropping other parts, this calls drop_edge for all children.

Having Self::drop_with_manager() only is not enough: To drop a Function, we should not require a manager lock, otherwise we might end up in a dead-lock (if we are in a .with_manager_exclusive() block). So we cannot provide a &Manager reference. Furthermore, when all Functions and ManagerRefs referencing a manager are gone and the manager needs to drop e.g. the apply cache, it may also provide a function that only forgets edges rather than actually dropping them, saving the (in this case) unnecessary work of changing reference counters etc.

Provided Methods§

Source

fn drop_with_manager<M: Manager<Edge = E>>(self, manager: &M)

Drop self

This is equivalent to self.drop_with(|e| manager.drop_edge(e)).

Among dropping other parts, this calls manager.drop_edge() for all children.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§