pub trait Value: Value + Borrow<Self::Borrowed> {
type Borrowed;
type Guard<G>: Guard<Self> + From<G>
where G: Guard<Self>;
const INDIRECT: bool;
// Required method
unsafe fn borrow_from_raw_unchecked(raw: &u64) -> &Self::Borrowed;
}Expand description
Values that can safely be stored in a ConcurrentMap.
Values may be either inline or indirect. An inline
value (e.g., u64) is stored directly in an edge and can be freely
copied. An indirect value (e.g., Box<T>) is a pointer to a separate
allocation; the pointer is stored in an edge.
Note: we don’t need Send or Sync bounds here.
It’s fine to create a concurrent map with non-Sync
values; the map instance just won’t implement Sync.
Required Associated Constants§
Required Associated Types§
Sourcetype Borrowed
type Borrowed
We need this extra layer of indirection relative to SequentialMap
because edges can be concurrently modified.
For an inline value, the sequential map can return a reference to the edge containing the value; the borrow checker ensures the edge is immutable. This is not true for the concurrent map, which instead needs to copy out the value and return a reference to the copy.
For an indirect value, the concurrent map copies out a pointer and interprets it as reference.
Required Methods§
Sourceunsafe fn borrow_from_raw_unchecked(raw: &u64) -> &Self::Borrowed
unsafe fn borrow_from_raw_unchecked(raw: &u64) -> &Self::Borrowed
§Safety
Caller must guarantee the following:
rawwas created from sequential::Value::into_raw`- There are no calls to
sequential::Value::from_raw_uncheckedwhilerawis live - This value is not mutated while
rawis live
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".