1use crate::docs::entry::{FnEntry, StdEntry};
2
3pub static STR: StdEntry = StdEntry {
4 name: "str",
5 description: "functions for string manipulation",
6 functions: FUNCTIONS,
7 since: None,
8 unstable: false,
9};
10
11static FUNCTIONS: &[&FnEntry] = &[
12 &BYTES,
13 &CHAR_AT,
14 &CHARS,
15 &CONCAT,
16 &CONTAINS,
17 &COUNT,
18 &ENDS_WITH,
19 &INDEX_OF,
20 &IS_EMPTY,
21 &JOIN,
22 &PAD_LEFT,
23 &PAD_RIGHT,
24 &REPEAT,
25 &REPLACE,
26 &REVERSE,
27 &SLICE,
28 &SPLIT,
29 &STARTS_WITH,
30 &TO_LOWER,
31 &TO_UPPER,
32 &TRIM,
33 &TRIM_END,
34 &TRIM_START,
35 &FORMAT,
36];
37
38static BYTES: FnEntry = FnEntry {
39 signature: "bytes(str)",
40 description: "returns an int array of the UTF-8 byte values of each character",
41 example: "get std::str::bytes\n\nbytes(\"hi\") // [104, 105]",
42 expected_output: None,
43 returns: "",
44 errors: None,
45 see_also: &[],
46 since: None,
47};
48
49static CHAR_AT: FnEntry = FnEntry {
50 signature: "char_at(str, index)",
51 description: "returns the character at the given index",
52 example: "get std::str::char_at\n\nchar_at(\"hello\", 1) // 'e'",
53 expected_output: None,
54 returns: "",
55 errors: None,
56 see_also: &[],
57 since: None,
58};
59
60static CHARS: FnEntry = FnEntry {
61 signature: "chars(str)",
62 description: "returns a char array of each character in the string",
63 example: "get std::str::chars\n\nchars(\"hi\") // ['h', 'i']",
64 expected_output: None,
65 returns: "",
66 errors: None,
67 see_also: &[],
68 since: None,
69};
70
71static CONCAT: FnEntry = FnEntry {
72 signature: "concat(a, b, ...)",
73 description: "concatenates any number of values into a single string",
74 example: "get std::str::concat\n\nconcat(\"hello\", \" \", \"world\") // hello world",
75 expected_output: None,
76 returns: "",
77 errors: None,
78 see_also: &[],
79 since: None,
80};
81
82static CONTAINS: FnEntry = FnEntry {
83 signature: "contains(str, sub)",
84 description: "true if str contains the substring sub",
85 example: "get std::str::contains\n\ncontains(\"hello\", \"ell\") // true",
86 expected_output: None,
87 returns: "",
88 errors: None,
89 see_also: &[],
90 since: None,
91};
92
93static COUNT: FnEntry = FnEntry {
94 signature: "count(str, sub)",
95 description: "returns the number of non-overlapping occurrences of sub in str",
96 example: "get std::str::count\n\ncount(\"banana\", \"an\") // 2",
97 expected_output: None,
98 returns: "",
99 errors: None,
100 see_also: &[],
101 since: None,
102};
103
104static ENDS_WITH: FnEntry = FnEntry {
105 signature: "ends_with(str, sub)",
106 description: "true if str ends with sub",
107 example: "get std::str::ends_with\n\nends_with(\"hello\", \"lo\") // true",
108 expected_output: None,
109 returns: "",
110 errors: None,
111 see_also: &[],
112 since: None,
113};
114
115static INDEX_OF: FnEntry = FnEntry {
116 signature: "index_of(str, sub)",
117 description: "returns the character index of the first occurrence of sub, or -1 if not found",
118 example: "get std::str::index_of\n\nindex_of(\"hello\", \"ll\") // 2",
119 expected_output: None,
120 returns: "",
121 errors: None,
122 see_also: &[],
123 since: None,
124};
125
126static IS_EMPTY: FnEntry = FnEntry {
127 signature: "is_empty(str)",
128 description: "true if the string has no characters",
129 example: "get std::str::is_empty\n\nis_empty(\"\") // true",
130 expected_output: None,
131 returns: "",
132 errors: None,
133 see_also: &[],
134 since: None,
135};
136
137static JOIN: FnEntry = FnEntry {
138 signature: "join(arr, delim)",
139 description: "joins an array into a string with delim between each element",
140 example: "get std::str::join\n\njoin([\"a\", \"b\", \"c\"], \"-\") // a-b-c",
141 expected_output: None,
142 returns: "",
143 errors: None,
144 see_also: &[],
145 since: None,
146};
147
148static PAD_LEFT: FnEntry = FnEntry {
149 signature: "pad_left(str, width, char)",
150 description: "pads str on the left with char until the total length reaches width",
151 example: "get std::str::pad_left\n\npad_left(\"5\", 3, '0') // 005",
152 expected_output: None,
153 returns: "",
154 errors: None,
155 see_also: &[],
156 since: None,
157};
158
159static PAD_RIGHT: FnEntry = FnEntry {
160 signature: "pad_right(str, width, char)",
161 description: "pads str on the right with char until the total length reaches width",
162 example: "get std::str::pad_right\n\npad_right(\"hi\", 5, '.') // hi...",
163 expected_output: None,
164 returns: "",
165 errors: None,
166 see_also: &[],
167 since: None,
168};
169
170static REPEAT: FnEntry = FnEntry {
171 signature: "repeat(str, count)",
172 description: "returns str repeated count times",
173 example: "get std::str::repeat\n\nrepeat(\"ab\", 3) // ababab",
174 expected_output: None,
175 returns: "",
176 errors: None,
177 see_also: &[],
178 since: None,
179};
180
181static REPLACE: FnEntry = FnEntry {
182 signature: "replace(str, from, to)",
183 description: "replaces all occurrences of from with to in str",
184 example: "get std::str::replace\n\nreplace(\"foo bar foo\", \"foo\", \"baz\") // baz bar baz",
185 expected_output: None,
186 returns: "",
187 errors: None,
188 see_also: &[],
189 since: None,
190};
191
192static REVERSE: FnEntry = FnEntry {
193 signature: "reverse(str)",
194 description: "returns str with characters in reverse order",
195 example: "get std::str::reverse\n\nreverse(\"hello\") // olleh",
196 expected_output: None,
197 returns: "",
198 errors: None,
199 see_also: &[],
200 since: None,
201};
202
203static SLICE: FnEntry = FnEntry {
204 signature: "slice(str, start, end)",
205 description: "returns a substring from start to end (exclusive)",
206 example: "get std::str::slice\n\nslice(\"hello\", 1, 4) // ell",
207 expected_output: None,
208 returns: "",
209 errors: None,
210 see_also: &[],
211 since: None,
212};
213
214static SPLIT: FnEntry = FnEntry {
215 signature: "split(str, delim)",
216 description: "splits str by delim and returns a string array",
217 example: "get std::str::split\n\nsplit(\"a,b,c\", \",\") // [\"a\", \"b\", \"c\"]",
218 expected_output: None,
219 returns: "",
220 errors: None,
221 see_also: &[],
222 since: None,
223};
224
225static STARTS_WITH: FnEntry = FnEntry {
226 signature: "starts_with(str, sub)",
227 description: "true if str starts with sub",
228 example: "get std::str::starts_with\n\nstarts_with(\"hello\", \"he\") // true",
229 expected_output: None,
230 returns: "",
231 errors: None,
232 see_also: &[],
233 since: None,
234};
235
236static TO_LOWER: FnEntry = FnEntry {
237 signature: "to_lower(str)",
238 description: "returns str with all characters converted to lowercase",
239 example: "get std::str::to_lower\n\nto_lower(\"HELLO\") // hello",
240 expected_output: None,
241 returns: "",
242 errors: None,
243 see_also: &[],
244 since: None,
245};
246
247static TO_UPPER: FnEntry = FnEntry {
248 signature: "to_upper(str)",
249 description: "returns str with all characters converted to uppercase",
250 example: "get std::str::to_upper\n\nto_upper(\"hello\") // HELLO",
251 expected_output: None,
252 returns: "",
253 errors: None,
254 see_also: &[],
255 since: None,
256};
257
258static TRIM: FnEntry = FnEntry {
259 signature: "trim(str)",
260 description: "removes leading and trailing whitespace from str",
261 example: "get std::str::trim\n\ntrim(\" hi \") // hi",
262 expected_output: None,
263 returns: "",
264 errors: None,
265 see_also: &[],
266 since: None,
267};
268
269static TRIM_END: FnEntry = FnEntry {
270 signature: "trim_end(str)",
271 description: "removes trailing whitespace from str",
272 example: "get std::str::trim_end\n\ntrim_end(\"hi \") // hi",
273 expected_output: None,
274 returns: "",
275 errors: None,
276 see_also: &[],
277 since: None,
278};
279
280static TRIM_START: FnEntry = FnEntry {
281 signature: "trim_start(str)",
282 description: "removes leading whitespace from str",
283 example: "get std::str::trim_start\n\ntrim_start(\" hi\") // hi",
284 expected_output: None,
285 returns: "",
286 errors: None,
287 see_also: &[],
288 since: None,
289};
290
291static FORMAT: FnEntry = FnEntry {
292 signature: "format(template, ...)",
293 description: "replaces each \"{}\" in template with the corresponding argument, in order",
294 example: "get std::str::format\n\nformat(\"{} is {}\", \"age\", 30) // age is 30",
295 expected_output: None,
296 returns: "",
297 errors: None,
298 see_also: &[],
299 since: None,
300};