pub struct MultiBorrowContext<'a, const N: usize, T, P = Option<T>>where
    T: Sized,
    P: PayloadContainer<Element = T> + 'static,
{ /* private fields */ }
Expand description

Multi-borrow context allows you to get as many unique references to elements in a pool as you want.

Implementations§

Tries to get a mutable reference to a pool element located at the given handle. The method could fail in three main reasons:

  1. A reference to an element is already taken - returning multiple mutable references to the same element is forbidden by Rust safety rules.
  2. You’re trying to get more references that the context could handle (there is not enough space in the internal handles storage) - in this case you must increase N.
  3. A given handle is invalid.
Performance

This method has O(N) complexity, internally it does linear search in the internal handles storage to enforce borrowing rules at runtime. The method is designed for small reference count (<32), where linear search is faster than hash set.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Casts self to a &dyn Any

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.