dogma:collections

import { Vec, Map } from "dogma:collections"

dogma:collections provides Vec<T> and Map<K, V> — richer alternatives to native arrays. All operations return new collections (functional/immutable style).

Vec<T>🔗

A dynamic array with a richer API than native [T].

import { Vec } from "dogma:collections"
import { println } from "dogma:core"

fn main() {
    let v = Vec::new()
    let v2 = v.push(1).push(2).push(3)
    println(f"Length: {v2.len()}")
}

Map<K, V>🔗

A key-value map. Internally a vector of pairs — suitable for small maps.

import { Map } from "dogma:collections"
import { println } from "dogma:core"

fn main() {
    let m = Map::new()
    let m2 = m.insert("health", 100).insert("mana", 50)
    match m2.get("health") {
        Some(v) => println(f"Health: {v}"),
        None => println("Not found"),
    }
}