swamp_script_std/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * Copyright (c) Peter Bjorklund. All rights reserved. https://github.com/swamp/script
 * Licensed under the MIT License. See LICENSE in the project root for license information.
 */

pub mod collections;
pub mod prelude;

use swamp_script_semantic::{modules::ResolvedModule, ResolvedRustType, TypeNumber};
pub const SPARSE_TYPE_ID: TypeNumber = 999;

#[must_use]
pub fn create_std_module() -> ResolvedModule {
    let std_module = ResolvedModule::new(&["std".to_string()]);
    let sparse_rust_type = ResolvedRustType {
        type_name: "Sparse".to_string(),
        number: SPARSE_TYPE_ID,
    };

    std_module
        .namespace
        .borrow_mut()
        .add_built_in_rust_type(sparse_rust_type)
        .expect("could not register Sparse type");

    std_module
}