Skip to main content

SListItem

Trait SListItem 

Source
pub unsafe trait SListItem<Tag>: Sized {
    // Required method
    fn get_node(&self) -> &mut SListNode<Tag>;

    // Provided method
    unsafe fn get_node_from_ptr<'a>(p: *mut u8) -> &'a mut SListNode<Tag>
       where Self: 'a { ... }
}
Expand description

A trait to return internal mutable SListNode for specified list.

The tag is used to distinguish different SListNodes within the same item. For only one ownership, you can use ().

§Safety

Implementors must ensure get_node returns a valid reference to the SListNode embedded within Self. Users must use UnsafeCell to hold SListNode to support interior mutability required by list operations.

Required Methods§

Source

fn get_node(&self) -> &mut SListNode<Tag>

Provided Methods§

Source

unsafe fn get_node_from_ptr<'a>(p: *mut u8) -> &'a mut SListNode<Tag>
where Self: 'a,

§Safety

This is just map from raw pointer to &mut SListNode.

You only have to implement this when using custom pointer type with abnormal address. Refer to Mixed Type Example

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§