You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A common reason to use intrusive data-structures is to be able to look up an element via one data-structure, and then perform some operation on the same element in a different data-structure.
AIUI, this cannot be done safely with this crate, as it requires the unsafe cursor_mut_from_ptr method to be called.
I think a safe interface could be made by having this crate own the allocator that produces elements. For example, a basic allocator could store elements in a Vec<T>, and then use Vec indices as the "pointers" used to identify elements. Safety would be ensured by checking indices against the length of the internal Vec.
This would not prevent logic errors (if you mixed elements from different allocators, you'd get garbage results) but it should all be safe.
An arena allocator could work similarly, but using real pointers and range checks instead.
The text was updated successfully, but these errors were encountered:
A common reason to use intrusive data-structures is to be able to look up an element via one data-structure, and then perform some operation on the same element in a different data-structure.
AIUI, this cannot be done safely with this crate, as it requires the unsafe
cursor_mut_from_ptr
method to be called.I think a safe interface could be made by having this crate own the allocator that produces elements. For example, a basic allocator could store elements in a
Vec<T>
, and then use Vec indices as the "pointers" used to identify elements. Safety would be ensured by checking indices against the length of the internal Vec.This would not prevent logic errors (if you mixed elements from different allocators, you'd get garbage results) but it should all be safe.
An arena allocator could work similarly, but using real pointers and range checks instead.
The text was updated successfully, but these errors were encountered: