MCPcopy Create free account
hub / github.com/RustPython/RustPython / Link

Interface Link

crates/common/src/linked_list.rs:75–93  ·  view source on GitHub ↗

Defines how a type is tracked within a linked list. In order to support storing a single type within multiple lists, accessing the list pointers is decoupled from the entry type. # Safety Implementations must guarantee that `Target` types are pinned in memory. In other words, when a node is inserted, the value will not be moved as long as it is stored in the list.

Source from the content-addressed store, hash-verified

73/// other words, when a node is inserted, the value will not be moved as long as
74/// it is stored in the list.
75pub unsafe trait Link {
76 /// Handle to the list entry.
77 ///
78 /// This is usually a pointer-ish type.
79 type Handle;
80
81 /// Node type.
82 type Target;
83
84 /// Convert the handle to a raw pointer without consuming the handle.
85 #[allow(clippy::wrong_self_convention)]
86 fn as_raw(handle: &Self::Handle) -> NonNull<Self::Target>;
87
88 /// Convert the raw pointer to a handle
89 unsafe fn from_raw(ptr: NonNull<Self::Target>) -> Self::Handle;
90
91 /// Return the pointers for a node
92 unsafe fn pointers(target: NonNull<Self::Target>) -> NonNull<Pointers<Self::Target>>;
93}
94
95/// Previous / next pointers.
96pub struct Pointers<T> {

Callers 1

__setitem__Method · 0.85

Implementers 1

core.rscrates/vm/src/object/core.rs

Calls

no outgoing calls

Tested by

no test coverage detected