Skip to main content

rl_lang/interpreter/stdlib/string/
mod.rs

1//! `std::str` - string manipulation functions.
2//!
3//! Note: the module name in rl imports is `str`, not `string`
4//! (registered as `Module::new("str")`).
5//!
6//! `format` uses `with_raw_function` for variadic `{}` placeholder substitution.
7//! `concat` also variadic - concatenates any number of values as strings.
8
9mod bytes;
10mod char_at;
11mod chars;
12mod concat;
13mod contains;
14mod count;
15mod ends_with;
16mod format;
17mod index_of;
18mod is_empty;
19mod join;
20mod pad_left;
21mod pad_right;
22mod repeat;
23mod replace;
24mod reverse;
25mod slice;
26mod split;
27mod starts_with;
28mod to_lower;
29mod to_upper;
30mod trim;
31mod trim_end;
32mod trim_start;
33
34use crate::interpreter::native::Module;
35
36pub const KEYWORDS: &[&str] = &[
37    "to_lower",
38    "to_upper",
39    "trim",
40    "trim_end",
41    "trim_start",
42    "repeat",
43    "is_empty",
44    "concat",
45    "char_at",
46    "bytes",
47    "chars",
48    "slice",
49    "contains",
50    "starts_with",
51    "ends_with",
52    "replace",
53    "pad_left",
54    "pad_right",
55    "split",
56    "join",
57    "count",
58    "index_of",
59    "format",
60];
61
62pub fn module() -> Module {
63    Module::new("str")
64        .with_function("to_upper", to_upper::std_to_upper)
65        .with_function("to_lower", to_lower::std_to_lower)
66        .with_function("trim", trim::std_trim)
67        .with_function("trim_end", trim_end::std_trim_end)
68        .with_function("trim_start", trim_start::std_trim_start)
69        .with_function("repeat", repeat::std_repeat)
70        .with_function("is_empty", is_empty::std_is_empty)
71        .with_raw_function("concat", concat::std_concat)
72        .with_function("char_at", char_at::std_char_at)
73        .with_function("bytes", bytes::std_bytes)
74        .with_function("chars", chars::std_chars)
75        .with_function("reverse", reverse::std_reverse)
76        .with_function("slice", slice::std_slice)
77        .with_function("contains", contains::std_contains)
78        .with_function("starts_with", starts_with::std_starts_with)
79        .with_function("ends_with", ends_with::std_ends_with)
80        .with_function("join", join::std_join)
81        .with_function("split", split::std_split)
82        .with_function("pad_right", pad_right::std_pad_right)
83        .with_function("pad_left", pad_left::std_pad_left)
84        .with_function("replace", replace::std_replace)
85        .with_function("count", count::std_count)
86        .with_function("index_of", index_of::std_index_of)
87        .with_raw_function("format", format::std_format)
88}