Skip to main content

rl_lang/interpreter/stdlib/types/
mod.rs

1//! `std::types` - type inspection and conversion functions.
2//!
3//! `is_*` functions check the runtime type of a value without conversion.
4//! `to_int` accepts hex strings prefixed with `0x`/`0X`.
5
6mod bin;
7mod bool;
8mod byte;
9mod char;
10mod error;
11mod float;
12mod hex;
13mod int;
14mod null;
15mod oct;
16mod string;
17
18use crate::interpreter::native::Module;
19
20pub const KEYWORDS: &[&str] = &[
21    "to_bin",
22    "to_bool",
23    "to_char",
24    "to_float",
25    "to_hex",
26    "to_int",
27    "to_oct",
28    "to_string",
29    "is_bool",
30    "is_null",
31    "is_char",
32    "is_int",
33    "is_string",
34    "is_float",
35    "is_error",
36    "error_unwrap",
37    "to_byte",
38    "is_byte",
39];
40
41pub fn module() -> Module {
42    Module::new("types")
43        .with_function("to_bin", bin::func)
44        .with_function("to_bool", bool::std_to_bool)
45        .with_function("to_char", char::std_to_char)
46        .with_function("to_float", float::std_to_float)
47        .with_function("to_hex", hex::func)
48        .with_function("to_int", int::std_to_int)
49        .with_function("to_oct", oct::func)
50        .with_function("to_string", string::std_to_string)
51        .with_function("is_bool", bool::std_is_bool)
52        .with_function("is_null", null::func)
53        .with_function("is_char", char::std_is_char)
54        .with_function("is_int", int::std_is_int)
55        .with_function("is_float", float::std_is_float)
56        .with_function("is_string", string::std_is_string)
57        .with_function("is_error", error::std_is_error)
58        .with_function("error_unwrap", error::std_error_unwrap)
59        .with_function("to_byte", byte::std_to_byte)
60        .with_function("is_byte", byte::std_is_byte)
61}