pub(crate) type Heap<T> = Heap<T>;
Aliased Type§
struct Heap<T> {
pub ptr: UnsafeCell<T>,
}
Fields§
§ptr: UnsafeCell<T>
Implementations
Source§impl<T> Heap<T>
impl<T> Heap<T>
Sourcepub fn boxed(v: T) -> Box<Heap<T>>
pub fn boxed(v: T) -> Box<Heap<T>>
This creates a Box
-wrapped Heap value. Setting a value inside Heap
object triggers a barrier, referring to the Heap object location,
hence why it is not safe to construct a temporary Heap value, assign
a non-null value and move it (e.g. typical object construction).
Using boxed Heap value guarantees that the underlying Heap value will not be moved when constructed.
pub fn set(&self, v: T)
pub fn get(&self) -> T
pub fn get_unsafe(&self) -> *mut T
Sourcepub unsafe fn handle(&self) -> Handle<T>
pub unsafe fn handle(&self) -> Handle<T>
Retrieves a Handle to the underlying value.
§Safety
This is only safe to do on a rooted object (which Heap is not, it needs to be additionally rooted), like RootedGuard, so use this only if you know what you’re doing.
§Notes
Since Heap values need to be informed when a change to underlying
value is made (e.g. via get()
), this does not allow to create
MutableHandle objects, which can bypass this and lead to crashes.