Skip to main content

PagedSparseSet

Struct PagedSparseSet 

Source
pub struct PagedSparseSet<K, const PAGE: usize = DEFAULT_PAGE, D: Directory = Flat> { /* private fields */ }
Expand description

A set of Keys with O(1) insert, remove and lookup, and a contiguous array of its keys.

  • PAGE is the number of slots per page of the sparse index; it must be non-zero. See DEFAULT_PAGE.
  • D picks the page directory: Flat (default) for dense keys, Radix for keys spread over the 64-bit range, or Tree. See crate::page.

The set holds at most one key per slot index. With plain integer keys that is the usual set semantics. With generational keys, insert refuses a key whose slot is held by another generation, and replace overwrites it.

Keys are kept in insertion order until a removal, which moves the last key into the gap.

§Set operations

union, intersection, difference, and symmetric_difference iterate over borrowed keys. The corresponding operators |, &, -, and ^ on borrowed sets create a set with the left operand’s page size and directory. The assignment operators |=, &=, -=, and ^= update a set in place. Removals can reorder keys by moving the last key into each gap. is_disjoint, is_subset, and is_superset test relationships between sets.

use paged_collections::page::Radix;
use paged_collections::sparse_set::PagedSparseSet;

let mut a: PagedSparseSet<u16, 4> = [1, 2].into_iter().collect();
let b: PagedSparseSet<u16, 64, Radix> = [2, 3].into_iter().collect();
assert_eq!((&a | &b).as_slice(), &[1, 2, 3]);
a &= &b;
assert!(a.is_subset(&b));

Implementations§

Source§

impl<K: Key, const PAGE: usize, D: Directory> PagedSparseSet<K, PAGE, D>

Source

pub const PAGE_SIZE: usize = PAGE

Number of slots per page of the sparse index.

Source

pub fn new() -> Self

Creates an empty set. No memory is allocated until the first insert.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates an empty set whose dense array can hold capacity keys without reallocating. Pages are still allocated on demand.

Source

pub fn len(&self) -> usize

Number of keys in the set.

Source

pub fn is_empty(&self) -> bool

Whether the set has no keys.

Source

pub fn capacity(&self) -> usize

Number of keys the dense array can hold without reallocating.

Source

pub fn allocated_pages(&self) -> usize

Number of allocated pages in the sparse index.

Source

pub fn reserve(&mut self, additional: usize)

Reserves room in the dense array for at least additional more keys.

Source

pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>

Like reserve, but returns an error instead of panicking or aborting when the capacity overflows or the allocation fails.

Source

pub fn position(&self, key: K) -> Option<usize>

Dense position of key, if it is in the set.

Positions index as_slice and change when keys are removed or the set is sorted.

Source

pub fn contains(&self, key: K) -> bool

Whether key is in the set.

Source

pub fn get(&self, key: K) -> Option<&K>

The stored key equal to key, including its generation.

§Examples
use paged_collections::sparse_set::PagedSparseSet;

let mut set: PagedSparseSet<usize> = PagedSparseSet::new();
set.insert(7);
assert_eq!(set.get(7), Some(&7));
assert_eq!(set.get(8), None);
Source

pub fn occupant(&self, index: usize) -> Option<&K>

The key occupying slot index, if any.

With generational keys this finds whichever generation is present.

Source

pub fn insert(&mut self, key: K) -> bool

Adds key and returns true, or returns false and leaves the set unchanged if its slot is already held (by key or by another key with the same index).

§Panics

Panics if the set already holds u32::MAX keys, or if a page or the directory cannot be allocated.

Source

pub fn replace(&mut self, key: K) -> Option<K>

Adds key, overwriting any key that holds its slot, and returns the key it overwrote.

An overwritten key keeps its dense position.

§Panics

As insert.

Source

pub fn remove(&mut self, key: K) -> bool

Removes key and returns whether it was present.

The last key moves into the removed key’s position.

Source

pub fn take(&mut self, key: K) -> Option<K>

Removes and returns the stored key equal to key, including its generation. The last key moves into the removed key’s position.

§Examples
use paged_collections::sparse_set::PagedSparseSet;

let mut set: PagedSparseSet<usize> = PagedSparseSet::new();
set.insert(7);
assert_eq!(set.take(7), Some(7));
assert_eq!(set.take(7), None);
Source

pub fn remove_occupant(&mut self, index: usize) -> Option<K>

Removes whichever key occupies slot index and returns it.

Source

pub fn retain(&mut self, keep: impl FnMut(&K) -> bool)

Keeps only the keys for which keep returns true.

keep is called once per key. Kept keys may change position.

Source

pub fn clear(&mut self)

Removes every key in O(1).

Pages stay allocated for reuse; use reset to free them.

Source

pub fn reset(&mut self)

Removes every key and frees every page. The dense array keeps its capacity.

Source

pub fn shrink_to_fit(&mut self)

Shrinks the dense array and the page directory. Frees every page if the set is empty.

Source

pub fn as_slice(&self) -> &[K]

The keys as a slice, in dense order.

Source

pub fn iter(&self) -> Iter<'_, K> ⓘ

Iterates over the keys in dense order.

Source

pub fn drain(&mut self) -> Drain<'_, K> ⓘ

Removes every key and returns them in dense order.

The set is empty as soon as this returns, even if the iterator is leaked; dropping it drops the keys not yet yielded. Pages and the dense array’s capacity are kept, as with clear.

use paged_collections::sparse_set::PagedSparseSet;

let mut set: PagedSparseSet<u32> = [5, 1, 9].into_iter().collect();
assert_eq!(set.drain().collect::<Vec<_>>(), [5, 1, 9]);
assert!(set.is_empty() && !set.contains(5));
Source

pub fn extract_if<F: FnMut(&K) -> bool>( &mut self, pred: F, ) -> ExtractIf<'_, K, F, PAGE, D> ⓘ

Removes the keys for which pred returns true and yields them.

Each key is tested exactly once. A removal moves the last key into the gap, so keys are tested in dense order except that a moved key is tested next. Keys not yet tested when the iterator is dropped stay in the set; use retain if the removed keys are not needed.

use paged_collections::sparse_set::PagedSparseSet;

let mut set: PagedSparseSet<u32> = (0..6).collect();
let mut odd: Vec<u32> = set.extract_if(|&k| k % 2 == 1).collect();
odd.sort();
assert_eq!(odd, [1, 3, 5]);
assert_eq!(set.len(), 3);
Source

pub fn range(&self, keys: impl RangeBounds<K>) -> Range<'_, K, PAGE, D> ⓘ

Iterates over the keys whose slot index lies between the slot indices of the bounds, in slot-index order.

The bounds are keys, compared by Key::index: for plain integer keys this is the usual key range, independent of dense order. A generational key bounds by its index only. An empty or inverted range yields nothing.

This walks the sparse index: it costs O(pages and slots in the range), including slots left stale by clear (which reset frees), not O(keys yielded).

use paged_collections::sparse_set::PagedSparseSet;

let set: PagedSparseSet<u32, 4> = [9, 2, 30, 5].into_iter().collect();
assert_eq!(set.range(3..=30).copied().collect::<Vec<_>>(), [5, 9, 30]);
assert_eq!((set.first(), set.last()), (Some(&2), Some(&30)));
assert_eq!(set.next_occupant(6), Some(&9));
Source

pub fn first(&self) -> Option<&K>

The key with the smallest slot index. Costs as range.

Source

pub fn last(&self) -> Option<&K>

The key with the largest slot index. Costs as range.

Source

pub fn next_occupant(&self, index: usize) -> Option<&K>

The key at slot index or the first one after it.

Source

pub fn prev_occupant(&self, index: usize) -> Option<&K>

The key at slot index or the last one before it.

Source

pub fn pop_first(&mut self) -> Option<K>

Removes and returns the key with the smallest slot index.

Source

pub fn pop_last(&mut self) -> Option<K>

Removes and returns the key with the largest slot index.

Source

pub fn difference<'a, const P2: usize, D2: Directory>( &'a self, other: &'a PagedSparseSet<K, P2, D2>, ) -> Difference<'a, K, P2, D2> ⓘ

Iterates over keys in self absent from other, in self’s dense order.

use paged_collections::sparse_set::PagedSparseSet;

let a: PagedSparseSet<u16> = [3, 1, 2].into_iter().collect();
let b: PagedSparseSet<u16> = [1, 4].into_iter().collect();
assert!(a.difference(&b).copied().eq([3, 2]));
Source

pub fn intersection<'a, const P2: usize, D2: Directory>( &'a self, other: &'a PagedSparseSet<K, P2, D2>, ) -> Intersection<'a, K, PAGE, D, P2, D2> ⓘ

Iterates over keys present in both sets.

Order follows the smaller set’s dense order, or self’s dense order if the sets contain the same number of keys.

use paged_collections::sparse_set::PagedSparseSet;

let a: PagedSparseSet<u16> = [1, 2, 3].into_iter().collect();
let b: PagedSparseSet<u16> = [2, 1].into_iter().collect();
assert!(a.intersection(&b).copied().eq([2, 1]));
Source

pub fn symmetric_difference<'a, const P2: usize, D2: Directory>( &'a self, other: &'a PagedSparseSet<K, P2, D2>, ) -> SymmetricDifference<'a, K, PAGE, D, P2, D2> ⓘ

Iterates over keys present in exactly one set.

Yields self.difference(other), then other.difference(self). Different generations of the same slot are unequal, so both are yielded. Collecting into a PagedSparseSet keeps self’s key because insert refuses an occupied slot.

use paged_collections::sparse_set::PagedSparseSet;

let a: PagedSparseSet<u16> = [3, 1, 2].into_iter().collect();
let b: PagedSparseSet<u16> = [2, 5, 4].into_iter().collect();
assert!(a.symmetric_difference(&b).copied().eq([3, 1, 5, 4]));
Source

pub fn union<'a, const P2: usize, D2: Directory>( &'a self, other: &'a PagedSparseSet<K, P2, D2>, ) -> Union<'a, K, PAGE, D> ⓘ

Iterates over keys present in either set.

Yields self’s keys in dense order, then other.difference(self). Different generations of the same slot are unequal, so both are yielded. Collecting into a PagedSparseSet keeps self’s key because insert refuses an occupied slot.

use paged_collections::sparse_set::PagedSparseSet;

let a: PagedSparseSet<u16> = [3, 1, 2].into_iter().collect();
let b: PagedSparseSet<u16> = [2, 5, 4].into_iter().collect();
assert!(a.union(&b).copied().eq([3, 1, 2, 5, 4]));
Source

pub fn is_disjoint<const P2: usize, D2: Directory>( &self, other: &PagedSparseSet<K, P2, D2>, ) -> bool

Whether the sets have no keys in common. Iterates over the smaller set.

use paged_collections::sparse_set::PagedSparseSet;

let a: PagedSparseSet<u16> = [1, 2].into_iter().collect();
let b: PagedSparseSet<u16> = [3].into_iter().collect();
assert!(a.is_disjoint(&b));
Source

pub fn is_subset<const P2: usize, D2: Directory>( &self, other: &PagedSparseSet<K, P2, D2>, ) -> bool

Whether every key in self is also in other.

use paged_collections::sparse_set::PagedSparseSet;

let a: PagedSparseSet<u16> = [2].into_iter().collect();
let b: PagedSparseSet<u16> = [1, 2].into_iter().collect();
assert!(a.is_subset(&b));
Source

pub fn is_superset<const P2: usize, D2: Directory>( &self, other: &PagedSparseSet<K, P2, D2>, ) -> bool

Whether every key in other is also in self.

use paged_collections::sparse_set::PagedSparseSet;

let a: PagedSparseSet<u16> = [1, 2].into_iter().collect();
let b: PagedSparseSet<u16> = [2].into_iter().collect();
assert!(a.is_superset(&b));
Source

pub fn sort_by(&mut self, compare: impl FnMut(&K, &K) -> Ordering)

Sorts the dense array by compare, keeping the order of equal keys, and updates the index.

If compare panics, the keys are left in an unspecified order but the set stays consistent.

Source

pub fn sort_by_key<T: Ord>(&mut self, f: impl FnMut(&K) -> T)

Sorts the dense array by a key function, keeping the order of keys with equal sort keys, and updates the index.

If f panics, the keys are left in an unspecified order but the set stays consistent.

Source

pub fn sort(&mut self)
where K: Ord,

Sorts the dense array in ascending order and updates the index.

Stable, which matters only if equal keys can be told apart; prefer sort_unstable otherwise: it allocates nothing.

Source

pub fn sort_unstable_by(&mut self, compare: impl FnMut(&K, &K) -> Ordering)

Sorts the dense array by compare (unstable) and updates the index.

If compare panics, the keys are left in an unspecified order but the set stays consistent.

Source

pub fn sort_unstable_by_key<T: Ord>(&mut self, f: impl FnMut(&K) -> T)

Sorts the dense array by a key function (unstable) and updates the index.

If f panics, the keys are left in an unspecified order but the set stays consistent.

Source

pub fn sort_unstable(&mut self)
where K: Ord,

Sorts the dense array in ascending order (unstable) and updates the index.

Trait Implementations§

Source§

impl<K: Key, const PAGE: usize, D: Directory, const P2: usize, D2: Directory> BitAnd<&PagedSparseSet<K, P2, D2>> for &PagedSparseSet<K, PAGE, D>

Collects the intersection into a new set.

Source§

type Output = PagedSparseSet<K, PAGE, D>

The resulting type after applying the & operator.
Source§

fn bitand(self, other: &PagedSparseSet<K, P2, D2>) -> Self::Output

Performs the & operation. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory, const P2: usize, D2: Directory> BitAndAssign<&PagedSparseSet<K, P2, D2>> for PagedSparseSet<K, PAGE, D>

Keeps the keys present in both sets. Swap removal can reorder keys.

Source§

fn bitand_assign(&mut self, other: &PagedSparseSet<K, P2, D2>)

Performs the &= operation. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory, const P2: usize, D2: Directory> BitOr<&PagedSparseSet<K, P2, D2>> for &PagedSparseSet<K, PAGE, D>

Collects the union into a new set.

Source§

type Output = PagedSparseSet<K, PAGE, D>

The resulting type after applying the | operator.
Source§

fn bitor(self, other: &PagedSparseSet<K, P2, D2>) -> Self::Output

Performs the | operation. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory, const P2: usize, D2: Directory> BitOrAssign<&PagedSparseSet<K, P2, D2>> for PagedSparseSet<K, PAGE, D>

Inserts the right operand’s keys in dense order, keeping occupied slots.

Source§

fn bitor_assign(&mut self, other: &PagedSparseSet<K, P2, D2>)

Performs the |= operation. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory, const P2: usize, D2: Directory> BitXor<&PagedSparseSet<K, P2, D2>> for &PagedSparseSet<K, PAGE, D>

Collects the symmetric difference into a new set.

Source§

type Output = PagedSparseSet<K, PAGE, D>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: &PagedSparseSet<K, P2, D2>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory, const P2: usize, D2: Directory> BitXorAssign<&PagedSparseSet<K, P2, D2>> for PagedSparseSet<K, PAGE, D>

Toggles each key in the right operand. Swap removal can reorder keys. When the operands hold different generations of the same slot, the left operand keeps its key and skips the right operand’s key.

Source§

fn bitxor_assign(&mut self, other: &PagedSparseSet<K, P2, D2>)

Performs the ^= operation. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory> Clone for PagedSparseSet<K, PAGE, D>
where D::Store<Slot, PAGE>: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Key + Debug, const PAGE: usize, D: Directory> Debug for PagedSparseSet<K, PAGE, D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory> Default for PagedSparseSet<K, PAGE, D>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, K: Key + Deserialize<'de>, const PAGE: usize, D: Directory> Deserialize<'de> for PagedSparseSet<K, PAGE, D>

Available on crate feature serde only.

Deserializes from a sequence of keys. A key whose slot is already taken is skipped, as HashSet skips duplicates.

Memory follows the key indices, not the input length: with the Flat directory one large index allocates a directory entry for every page below it, and an index near usize::MAX panics. For untrusted input, use Radix or Tree, or validate the keys first.

Source§

fn deserialize<De: Deserializer<'de>>( deserializer: De, ) -> Result<Self, De::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory> Eq for PagedSparseSet<K, PAGE, D>

Exact key equality gives sets an equivalence relation under PartialEq.

Source§

impl<'a, K: Key + 'a, const PAGE: usize, D: Directory> Extend<&'a K> for PagedSparseSet<K, PAGE, D>

Source§

fn extend<I: IntoIterator<Item = &'a K>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: T)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory> Extend<K> for PagedSparseSet<K, PAGE, D>

Source§

fn extend<I: IntoIterator<Item = K>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: T)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<K: Key, const PAGE: usize, D: SharedDirectory> From<PagedSparseSet<K, PAGE, D>> for ConcurrentSparseSet<K, PAGE, D>

Available on crate feature concurrent only.
Source§

fn from(inner: PagedSparseSet<K, PAGE, D>) -> Self

Converts to this type from the input type.
Source§

impl<K: Key, const PAGE: usize, D: Directory> FromIterator<K> for PagedSparseSet<K, PAGE, D>

Source§

fn from_iter<I: IntoIterator<Item = K>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<K: Key + Hash, const PAGE: usize, D: Directory> Hash for PagedSparseSet<K, PAGE, D>

Hashes the keys in any order, consistent with PartialEq.

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, K: Key, const PAGE: usize, D: Directory> IntoIterator for &'a PagedSparseSet<K, PAGE, D>

Source§

type Item = &'a K

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, K>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory> IntoIterator for PagedSparseSet<K, PAGE, D>

Source§

type Item = K

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<K>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, K: Key + Sync, const PAGE: usize, D: Directory> IntoParallelIterator for &'a PagedSparseSet<K, PAGE, D>

Available on crate feature rayon only.
Source§

type Item = &'a K

The type of item that the parallel iterator will produce.
Source§

type Iter = Iter<'a, K>

The parallel iterator type that will be created.
Source§

fn into_par_iter(self) -> Self::Iter

Converts self into a parallel iterator. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory, const P2: usize, D2: Directory> PartialEq<PagedSparseSet<K, P2, D2>> for PagedSparseSet<K, PAGE, D>

Compares exact keys with contains, in any order and across page sizes and directories.

Source§

fn eq(&self, other: &PagedSparseSet<K, P2, D2>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<K: Key + Serialize, const PAGE: usize, D: Directory> Serialize for PagedSparseSet<K, PAGE, D>

Available on crate feature serde only.

Serializes as a sequence of keys in dense order.

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory, const P2: usize, D2: Directory> Sub<&PagedSparseSet<K, P2, D2>> for &PagedSparseSet<K, PAGE, D>

Collects the difference into a new set.

Source§

type Output = PagedSparseSet<K, PAGE, D>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &PagedSparseSet<K, P2, D2>) -> Self::Output

Performs the - operation. Read more
Source§

impl<K: Key, const PAGE: usize, D: Directory, const P2: usize, D2: Directory> SubAssign<&PagedSparseSet<K, P2, D2>> for PagedSparseSet<K, PAGE, D>

Removes keys present in the right operand. Swap removal can reorder keys.

Source§

fn sub_assign(&mut self, other: &PagedSparseSet<K, P2, D2>)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl<K, const PAGE: usize, D> Forget for PagedSparseSet<K, PAGE, D>

§

impl<K, const PAGE: usize, D> Freeze for PagedSparseSet<K, PAGE, D>
where Vec<K>: Freeze, <D as Directory>::Store<Option<NonZero<u32>>, PAGE>: Freeze,

§

impl<K, const PAGE: usize, D> Move for PagedSparseSet<K, PAGE, D>

§

impl<K, const PAGE: usize, D> RefUnwindSafe for PagedSparseSet<K, PAGE, D>

§

impl<K, const PAGE: usize, D> Send for PagedSparseSet<K, PAGE, D>
where Vec<K>: Send, <D as Directory>::Store<Option<NonZero<u32>>, PAGE>: Send,

§

impl<K, const PAGE: usize, D> Sync for PagedSparseSet<K, PAGE, D>
where Vec<K>: Sync, <D as Directory>::Store<Option<NonZero<u32>>, PAGE>: Sync,

§

impl<K, const PAGE: usize, D> Unpin for PagedSparseSet<K, PAGE, D>
where Vec<K>: Unpin, <D as Directory>::Store<Option<NonZero<u32>>, PAGE>: Unpin,

§

impl<K, const PAGE: usize, D> UnsafeUnpin for PagedSparseSet<K, PAGE, D>
where Vec<K>: UnsafeUnpin, <D as Directory>::Store<Option<NonZero<u32>>, PAGE>: UnsafeUnpin,

§

impl<K, const PAGE: usize, D> UnwindSafe for PagedSparseSet<K, PAGE, D>
where Vec<K>: UnwindSafe, <D as Directory>::Store<Option<NonZero<u32>>, PAGE>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'data, I> IntoParallelRefIterator<'data> for I
where I: 'data + ?Sized, &'data I: IntoParallelIterator,

Source§

type Iter = <&'data I as IntoParallelIterator>::Iter

The type of the parallel iterator that will be returned.
Source§

type Item = <&'data I as IntoParallelIterator>::Item

The type of item that the parallel iterator will produce. This will typically be an &'data T reference type.
Source§

fn par_iter(&'data self) -> <I as IntoParallelRefIterator<'data>>::Iter

Converts self into a parallel iterator. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.