Expand description
Compile-time stack list implementation for type-safe stack operations.
A CStackList is a List with guaranteed memory layout (repr(C)). The tail is stored
first, so appending items does not change the memory layout of prior items (though the required
alignment may increase). CNil<T> represents the empty list where T is used to hide the
tail for std::ops::RangeTo and std::ops::RangeToInclusive indexing.
See https://doc.rust-lang.org/stable/reference/type-layout.html#r-layout.repr.c.struct
§Indexing
Indexing is done using the typenum::uint::UInt type integral constants.
Because the std::ops::Range trait requires a start and end that are the same type,
it cannot be implemented for List types. Instead we use the std::ops::RangeFrom and
std::ops::RangeTo
traits. To Access a range of elements, you can use the syntax list[..end][start..].
§Example
use cel_runtime::*;
use typenum::*;
let list = (1, 2.5, 3, 4, "world", "Hello").into_c_stack_list();
assert_eq!(list[..U5::new()][U2::new()..], (3, 4, "world").into_c_stack_list());Indexing out of bounds will result in a compile error.
use cel_runtime::c_stack_list::*;
use typenum::*;
let list = (1, 2.5, 3, 4, "world", "Hello").into_c_stack_list()[U6::new()];Structs§
- CNil
- Empty
repr(C)list used as the tail sentinel forCStackList. - CStack
List - A list using a guaranteed memory layout (
repr(C)), with tail stored first so appending items does not change the memory layout of prior items.
Traits§
- CStack
List Head Limit - A trait describing the memory layout of a
CStackList. Describes the memory layout of aCStackList’s head and tail boundary. - CStack
List Head Padded - Indicates whether the head element is padded to satisfy alignment.
- IntoC
Stack List - Converts tuples and list-like values into a source-ordered
CStackList. - Into
Rust Tuple - Moves a canonical list into a native Rust tuple in logical source order.