Skip to main content

Module list

Module list 

Source
Expand description

List, a mutable sequence whose handles all see each change.

A List is a shared handle, like Rc<RefCell<Vec<T>>>: cloning it bumps the reference count, and a mutation through one handle is seen through all of them. That is why the mutating methods take &self, and why elements are returned by value rather than by reference. It is not synchronized, so it is neither Send nor Sync.

Converting an Any into a List<T> shares an ffi.List whose elements are all T; an ffi.Array, or a list whose elements need converting, is copied into a new list.

A read checks and converts an element in its cell, in place. While it does, the element type’s extra_check and convert_fallback, and the Drop of a value the read releases, must not modify that list.

Structs§

Iter
Iterator over a List, created by List::iter. Each step yields Ok(T), or the TYPE_ERROR List::get would give when the element at that position is not a T (another handle to the same list may have put it there), and then moves on to the next element. It re-reads the length on every step, so it stays in bounds if the list is mutated meanwhile; iterating from the back (rev) pins the end at the first back step.
List
A mutable, reference-counted sequence of T, passed across languages as ffi.List.
ListObj
The object behind a List, laid out as the C++ ListObj. Unlike ffi.Array, the element buffer data is a separate allocation that the runtime replaces when the list grows.