rune::modules::vec

Function module

Source
pub fn module() -> Result<Module, ContextError>
Expand description

The Vec dynamic vector.

The vector type is a growable dynamic array that can hold an ordered collection of values.

Tuples in Rune are declared with the special [a] syntax, but can also be interacted with through the fundamental Vec type.

The vector type has support for native pattern matching:

let value = [1, 2];

if let [a, b] = value {
    assert_eq!(a, 1);
    assert_eq!(b, 2);
}

ยงExamples

let empty = [];
let one = [10];
let two = [10, 20];

assert!(empty.is_empty());
assert_eq!(one.0, 10);
assert_eq!(two.0, 10);
assert_eq!(two.1, 20);