Crate c_linked_list [] [src]

This crate provides utilities for working with NULL-terminated linked lists provided by C code. Suppose you call a foreign function which returns either NULL or a pointer to a node of the following C type.

struct LinkedListNode {
    int value;
    struct LinkedListNode *next;
};

You can use this library to wrap the C linked list in a rust type, allowing operations such as iteration to be performed on it.

let some_c_linked_list = foreign_function_which_returns_c_linked_list();
let rust_linked_list = unsafe { CLinkedListMut::from_ptr(some_c_linked_list, |n| n.next) };
for (i, node) in rust_linked_list.iter().enumerate() {
    println!("some_c_linked_list[{}] == {}", i, node.value);
}

Structs

CLinkedListConst

Wraps a C linked list comprised of const pointers between nodes.

CLinkedListConstIter

Iterator over a CLinkedListConst. Returns immutable references to the nodes of the list.

CLinkedListMut

Wraps a C linked list comprised of mutable pointers between nodes.

CLinkedListMutIter

Iterator over a CLinkedListMut. Returns references to the nodes of the list.

CLinkedListMutIterMut

Iterator over a CLinkedListMut. Returns mutable references to the nodes of the list.