Types

Trait Types 

Source
pub trait Types {
    type Id: Id;
    type Protected;
    type Removed;
    type Unprotected;
}
Expand description

Types used in a PinList. This trait is used to avoid an excessive number of generic parameters on PinList and related types.

Generally you won’t want to implement this trait directly — instead you can create ad-hoc implementations by using dyn Trait syntax, for example:

type PinListTypes = dyn pin_list::Types<
    Id = pin_list::id::Checked,
    Protected = (),
    Removed = (),
    Unprotected = (),
>;
type PinList = pin_list::PinList<PinListTypes>;

Required Associated Types§

Source

type Id: Id

The ID type this list uses to ensure that different PinLists are not mixed up.

This crate provides a couple built-in ID types, but you can also define your own:

  • id::Checked: IDs are allocated with a single global atomic u64 counter.
  • id::Unchecked: The responsibility is left up to the user to ensure that different PinLists are not incorrectly mixed up. Using this is unsafe.
  • id::DebugChecked: Equivalent to id::Checked when debug_assertions are enabled, but id::Unchecked in release.
  • id::Lifetime: A fully statically checked ID based on invariant lifetimes and HRTBs — this is the same technique as used by GhostCell. While theoretically the best option, its infectious nature makes it not very useful in practice.
Source

type Protected

Data owned by each node in the list (before it has been removed) and protected by the list. This is only accessible when the list is.

When the node is removed from the list, this value is replaced with Removed.

Source

type Removed

Data owned by each node after it has been removed from the list.

Source

type Unprotected

Data owned by each node in the list but not protected by the list.

This is always accessible by shared reference from the node itself without accessing the list, and is acessible by shared reference from the PinList.

Implementors§