core::collections::frozen
本頁內容
API 參考只有英文版,由標準函式庫原始碼中的英文文件註解產生。
FrozenList, FrozenDict and
FrozenSet: a collection that no one can change any more, shared
between threads without a lock and without a copy.
xs.freeze() takes the collection's storage over in O(1) and leaves
xs empty, so a handle the compiler did not see (code in unsafe)
changes a new, empty collection, never what the readers read. Only
elements that are Send + Sync themselves can be frozen, so nothing
reached from a frozen collection can change either.
Structs
FrozenListSource
pub struct FrozenList<T>A list that never changes: Sync, so threads share one without a
lock (a par closure may capture it, a static may hold it, a
hand-off leaves it shared). Made by List::freeze; to_list gives
a list to change.
An empty frozen list.
The number of elements.
truewhen the list has no element.Element
i, ornoneout of bounds.The first element;
nonewhen empty.The last element;
nonewhen empty.The elements front to back.
Views of
[0, mid)and[mid, len); panics ifmidis past the length.Views of
sizeconsecutive elements, sliding by one (size> 0).Views of
sizeelements in order, the last one shorter (size> 0):par::map(xs.chunks(n), ..)reads them in parallel.A new list holding the elements, free to change.
truewhen an element equalsx.The index of
xin the sorted list, ornone.
Trait implementations 10
unsafe impl<T: Send + Sync> Sync for FrozenList<T>impl<T> Index<usize> for FrozenList<T>impl<T> Sliceable<Range<usize>> for FrozenList<T>impl<T> IntoIterator for FrozenList<T>impl<T: Send + Sync> Default for FrozenList<T>impl<T> Clone for FrozenList<T>impl<T: PartialEq> PartialEq for FrozenList<T>impl<T: Eq> Eq for FrozenList<T>impl<T: Hash> Hash for FrozenList<T>impl<T: Debug> Debug for FrozenList<T>
FrozenDictSource
pub struct FrozenDict<K, V, S = RandomState>A dict that never changes: Sync, so threads share one without a
lock. Made by Dict::freeze; to_dict gives a dict to change.
An empty frozen dict.
The number of entries.
truewhen the dict has no entry.The value under
k;nonewhenkis absent.The value under
k;defaultwhenkis absent.truewhenkhas an entry.The keys, in insertion order.
The values, in insertion order.
The
(key, value)pairs, in insertion order.What builds the dict's hashers.
A new dict holding the entries, free to change.
Trait implementations 7
unsafe impl<K: Send + Sync, V: Send + Sync, S: Send + Sync> Sync for FrozenDict<K, V, S>impl<K: Hash, V, S: BuildHasher> Index<K> for FrozenDict<K, V, S>impl<K: Hash, V, S: BuildHasher> IntoIterator for FrozenDict<K, V, S>impl<K: Hash + Send + Sync, V: Send + Sync> Default for FrozenDict<K, V>impl<K, V, S> Clone for FrozenDict<K, V, S>impl<K: Hash, V: PartialEq, S: BuildHasher> PartialEq for FrozenDict<K, V, S>impl<K: Hash + Debug, V: Debug, S: BuildHasher> Debug for FrozenDict<K, V, S>
FrozenSetSource
pub struct FrozenSet<T, S = RandomState>A set that never changes: Sync, so threads share one without a
lock. Made by Set::freeze; to_set gives a set to change.
An empty frozen set.
The number of members.
truewhen the set has no member.truewhenxis a member.The members, in insertion order.
What builds the set's hashers.
A new set holding the members, free to change.
Trait implementations 6
unsafe impl<T: Send + Sync, S: Send + Sync> Sync for FrozenSet<T, S>impl<T: Hash, S: BuildHasher> IntoIterator for FrozenSet<T, S>impl<T: Hash + Send + Sync> Default for FrozenSet<T>impl<T, S> Clone for FrozenSet<T, S>impl<T: Hash, S: BuildHasher> PartialEq for FrozenSet<T, S>impl<T: Hash + Debug, S: BuildHasher> Debug for FrozenSet<T, S>