std1.0.0-beta-7 SafeC docs

Module collections::list

#include <std/collections/list.h> source

List<T> (doubly linked list)

struct List<int> l = std::List::new();
l.push_back(1); l.push_front(0);
?int first = l.pop_front();     // 0
l.free();

One node per element, holding the element by value; nodes come from the list's own NodePool (see node_pool.h), so push/pop don't hit the allocator per element and free() releases whole chunks. front()/back()/ find() hand out '?&T' into a node, valid until that node is removed.

A List owns its elements: it is a Drop type, and T may own something itself (String, Vec, ...). push_front/push_back take the element by value (one they can't store is dropped), pop_front/pop_back move it out, remove() drops the element it unlinks, and clear()/drop() drop every element still in the list.

Structs

ListNode
List