@shd101wyy/yo 0.1.25 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/.github/skills/yo-async-effects/SKILL.md +4 -4
  2. package/.github/skills/yo-async-effects/async-effects-recipes.md +40 -40
  3. package/.github/skills/yo-core-patterns/SKILL.md +1 -1
  4. package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +30 -26
  5. package/.github/skills/yo-project-workflow/SKILL.md +6 -3
  6. package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +34 -11
  7. package/.github/skills/yo-syntax/SKILL.md +7 -6
  8. package/.github/skills/yo-syntax/syntax-cheatsheet.md +78 -60
  9. package/.github/skills/yo-wasm-integration/wasm-integration-cheatsheet.md +3 -3
  10. package/README.md +10 -8
  11. package/out/cjs/index.cjs +583 -567
  12. package/out/cjs/yo-cli.cjs +664 -632
  13. package/out/cjs/yo-lsp.cjs +510 -485
  14. package/out/esm/index.mjs +538 -522
  15. package/out/types/src/codegen/codegen-c.d.ts +2 -2
  16. package/out/types/src/codegen/functions/collection.d.ts +2 -2
  17. package/out/types/src/codegen/functions/context.d.ts +3 -2
  18. package/out/types/src/codegen/types/collection.d.ts +2 -2
  19. package/out/types/src/codegen/utils/index.d.ts +3 -1
  20. package/out/types/src/doc/builder.d.ts +2 -2
  21. package/out/types/src/evaluator/calls/closure-type.d.ts +2 -2
  22. package/out/types/src/evaluator/calls/record-type.d.ts +11 -0
  23. package/out/types/src/evaluator/context.d.ts +8 -9
  24. package/out/types/src/evaluator/index.d.ts +3 -3
  25. package/out/types/src/evaluator/types/record.d.ts +14 -0
  26. package/out/types/src/evaluator/types/validation.d.ts +2 -2
  27. package/out/types/src/evaluator/values/anonymous-module.d.ts +5 -5
  28. package/out/types/src/evaluator/values/impl.d.ts +1 -1
  29. package/out/types/src/expr.d.ts +1 -4
  30. package/out/types/src/formatter.d.ts +11 -0
  31. package/out/types/src/function-value.d.ts +1 -1
  32. package/out/types/src/lsp/document-manager.d.ts +1 -1
  33. package/out/types/src/lsp/formatting.d.ts +2 -0
  34. package/out/types/src/module-manager.d.ts +3 -3
  35. package/out/types/src/tests/formatter.test.d.ts +1 -0
  36. package/out/types/src/types/creators.d.ts +3 -4
  37. package/out/types/src/types/definitions.d.ts +8 -19
  38. package/out/types/src/types/guards.d.ts +3 -3
  39. package/out/types/src/types/tags.d.ts +0 -1
  40. package/out/types/src/types/utils.d.ts +1 -1
  41. package/out/types/src/value-tag.d.ts +0 -1
  42. package/out/types/src/value.d.ts +6 -13
  43. package/out/types/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +1 -1
  45. package/std/alg/hash.yo +13 -21
  46. package/std/allocator.yo +25 -40
  47. package/std/async.yo +3 -7
  48. package/std/build.yo +105 -151
  49. package/std/cli/arg_parser.yo +184 -169
  50. package/std/collections/array_list.yo +350 -314
  51. package/std/collections/btree_map.yo +142 -131
  52. package/std/collections/deque.yo +132 -128
  53. package/std/collections/hash_map.yo +542 -566
  54. package/std/collections/hash_set.yo +623 -687
  55. package/std/collections/linked_list.yo +275 -293
  56. package/std/collections/ordered_map.yo +113 -85
  57. package/std/collections/priority_queue.yo +73 -73
  58. package/std/crypto/md5.yo +191 -95
  59. package/std/crypto/random.yo +56 -64
  60. package/std/crypto/sha256.yo +151 -107
  61. package/std/encoding/base64.yo +87 -81
  62. package/std/encoding/hex.yo +43 -50
  63. package/std/encoding/html.yo +56 -81
  64. package/std/encoding/html_char_utils.yo +7 -13
  65. package/std/encoding/html_entities.yo +2248 -2253
  66. package/std/encoding/json.yo +316 -224
  67. package/std/encoding/punycode.yo +86 -116
  68. package/std/encoding/toml.yo +67 -66
  69. package/std/encoding/utf16.yo +37 -44
  70. package/std/env.yo +62 -91
  71. package/std/error.yo +12 -20
  72. package/std/fmt/display.yo +5 -9
  73. package/std/fmt/index.yo +8 -14
  74. package/std/fmt/to_string.yo +330 -315
  75. package/std/fmt/writer.yo +58 -87
  76. package/std/fs/dir.yo +83 -102
  77. package/std/fs/file.yo +147 -180
  78. package/std/fs/metadata.yo +45 -78
  79. package/std/fs/temp.yo +55 -65
  80. package/std/fs/types.yo +27 -40
  81. package/std/fs/walker.yo +53 -68
  82. package/std/gc.yo +5 -8
  83. package/std/glob.yo +30 -43
  84. package/std/http/client.yo +107 -120
  85. package/std/http/http.yo +106 -96
  86. package/std/http/index.yo +4 -6
  87. package/std/imm/list.yo +88 -93
  88. package/std/imm/map.yo +528 -464
  89. package/std/imm/set.yo +52 -57
  90. package/std/imm/sorted_map.yo +340 -286
  91. package/std/imm/sorted_set.yo +57 -63
  92. package/std/imm/string.yo +404 -345
  93. package/std/imm/vec.yo +173 -181
  94. package/std/io/reader.yo +3 -6
  95. package/std/io/writer.yo +4 -8
  96. package/std/libc/assert.yo +5 -9
  97. package/std/libc/ctype.yo +32 -22
  98. package/std/libc/dirent.yo +26 -25
  99. package/std/libc/errno.yo +164 -90
  100. package/std/libc/fcntl.yo +52 -45
  101. package/std/libc/float.yo +66 -44
  102. package/std/libc/limits.yo +42 -33
  103. package/std/libc/math.yo +53 -82
  104. package/std/libc/signal.yo +72 -47
  105. package/std/libc/stdatomic.yo +217 -188
  106. package/std/libc/stdint.yo +5 -29
  107. package/std/libc/stdio.yo +5 -29
  108. package/std/libc/stdlib.yo +32 -39
  109. package/std/libc/string.yo +5 -23
  110. package/std/libc/sys/stat.yo +58 -56
  111. package/std/libc/time.yo +5 -19
  112. package/std/libc/unistd.yo +5 -20
  113. package/std/libc/wctype.yo +6 -9
  114. package/std/libc/windows.yo +26 -30
  115. package/std/log.yo +41 -55
  116. package/std/net/addr.yo +102 -97
  117. package/std/net/dns.yo +27 -28
  118. package/std/net/errors.yo +50 -49
  119. package/std/net/tcp.yo +113 -124
  120. package/std/net/udp.yo +55 -66
  121. package/std/os/env.yo +35 -33
  122. package/std/os/signal.yo +15 -25
  123. package/std/path.yo +276 -311
  124. package/std/prelude.yo +6316 -4333
  125. package/std/process/command.yo +87 -103
  126. package/std/process/index.yo +12 -31
  127. package/std/regex/compiler.yo +196 -95
  128. package/std/regex/flags.yo +58 -39
  129. package/std/regex/index.yo +157 -173
  130. package/std/regex/match.yo +20 -31
  131. package/std/regex/node.yo +134 -152
  132. package/std/regex/parser.yo +283 -259
  133. package/std/regex/unicode.yo +172 -202
  134. package/std/regex/vm.yo +155 -171
  135. package/std/string/index.yo +5 -7
  136. package/std/string/rune.yo +45 -55
  137. package/std/string/string.yo +937 -964
  138. package/std/string/string_builder.yo +94 -104
  139. package/std/string/unicode.yo +46 -64
  140. package/std/sync/channel.yo +72 -73
  141. package/std/sync/cond.yo +31 -36
  142. package/std/sync/mutex.yo +30 -32
  143. package/std/sync/once.yo +13 -16
  144. package/std/sync/rwlock.yo +26 -31
  145. package/std/sync/waitgroup.yo +20 -25
  146. package/std/sys/advise.yo +16 -24
  147. package/std/sys/bufio/buf_reader.yo +77 -93
  148. package/std/sys/bufio/buf_writer.yo +52 -65
  149. package/std/sys/clock.yo +4 -9
  150. package/std/sys/constants.yo +77 -61
  151. package/std/sys/copy.yo +4 -10
  152. package/std/sys/dir.yo +26 -43
  153. package/std/sys/dns.yo +41 -61
  154. package/std/sys/errors.yo +95 -103
  155. package/std/sys/events.yo +45 -57
  156. package/std/sys/externs.yo +319 -267
  157. package/std/sys/fallocate.yo +7 -11
  158. package/std/sys/fcntl.yo +14 -22
  159. package/std/sys/file.yo +26 -40
  160. package/std/sys/future.yo +5 -8
  161. package/std/sys/iov.yo +12 -25
  162. package/std/sys/lock.yo +12 -13
  163. package/std/sys/mmap.yo +38 -43
  164. package/std/sys/path.yo +3 -8
  165. package/std/sys/perm.yo +7 -21
  166. package/std/sys/pipe.yo +5 -12
  167. package/std/sys/process.yo +23 -29
  168. package/std/sys/seek.yo +10 -12
  169. package/std/sys/signal.yo +7 -13
  170. package/std/sys/signals.yo +52 -35
  171. package/std/sys/socket.yo +63 -58
  172. package/std/sys/socketpair.yo +3 -6
  173. package/std/sys/sockinfo.yo +11 -20
  174. package/std/sys/statfs.yo +11 -34
  175. package/std/sys/statx.yo +25 -52
  176. package/std/sys/sysinfo.yo +15 -20
  177. package/std/sys/tcp.yo +62 -92
  178. package/std/sys/temp.yo +5 -9
  179. package/std/sys/time.yo +5 -15
  180. package/std/sys/timer.yo +6 -11
  181. package/std/sys/tty.yo +10 -18
  182. package/std/sys/udp.yo +22 -39
  183. package/std/sys/umask.yo +3 -6
  184. package/std/sys/unix.yo +33 -52
  185. package/std/testing/bench.yo +49 -52
  186. package/std/thread.yo +10 -15
  187. package/std/time/datetime.yo +105 -89
  188. package/std/time/duration.yo +43 -56
  189. package/std/time/instant.yo +13 -18
  190. package/std/time/sleep.yo +5 -9
  191. package/std/url/index.yo +184 -209
  192. package/std/worker.yo +6 -10
  193. package/out/types/src/evaluator/calls/module-type.d.ts +0 -11
  194. package/out/types/src/evaluator/types/module.d.ts +0 -19
package/std/imm/string.yo CHANGED
@@ -2,450 +2,491 @@
2
2
  //!
3
3
  //! Uses atomic reference counting for safe sharing across threads.
4
4
  //! All "modification" operations return a new string; the original is unchanged.
5
-
6
- { GlobalAllocator } :: import "../allocator.yo";
5
+ { GlobalAllocator } :: import("../allocator.yo");
7
6
  { malloc, free } :: GlobalAllocator;
8
- { memcpy, memcmp } :: import "../libc/string.yo";
9
- { rune } :: import "../string/rune.yo";
10
- std_string :: import "../string";
11
- { ToString } :: import "../fmt/to_string.yo";
12
- imm_list :: import "./list.yo";
13
-
14
- _min :: (fn(a: usize, b: usize) -> usize)(
7
+ { memcpy, memcmp } :: import("../libc/string.yo");
8
+ { rune } :: import("../string/rune.yo");
9
+ std_string :: import("../string");
10
+ { ToString } :: import("../fmt/to_string.yo");
11
+ imm_list :: import("./list.yo");
12
+ _min :: (fn(a : usize, b : usize) -> usize)(
15
13
  cond((a < b) => a, true => b)
16
14
  );
17
-
18
- _alloc_bytes :: (fn(n: usize) -> *(u8))(
19
- match(malloc(n),
15
+ _alloc_bytes :: (fn(n : usize) -> *(u8))(
16
+ match(
17
+ malloc(n),
20
18
  .Some(p) => *(u8)(p),
21
19
  .None => panic("imm.String: allocation failed")
22
20
  )
23
21
  );
24
-
25
22
  /// Immutable, thread-safe UTF-8 string.
26
23
  ///
27
24
  /// Uses atomic RC — cheap to clone, safe to share across threads.
28
25
  /// No mutable operations. All "modification" methods return a new String.
29
26
  ///
30
27
  /// Empty strings are zero-allocation (null pointer, zero length).
31
- String :: atomic object(
32
- _ptr : ?*(u8),
33
- _len : usize,
34
- _capacity : usize
28
+ String :: atomic(
29
+ object(
30
+ _ptr : ?*(u8),
31
+ _len : usize,
32
+ _capacity : usize
33
+ )
35
34
  );
36
-
37
- impl(String, Dispose(
38
- dispose : (fn(self: Self) -> unit)({
39
- match(self._ptr,
40
- .Some(p) => free(.Some(*(void)(p))),
41
- .None => ()
42
- );
43
- })
44
- ));
45
-
46
- impl(String,
35
+ impl(
36
+ String,
37
+ Dispose(
38
+ dispose : (fn(self : Self) -> unit)({
39
+ match(
40
+ self._ptr,
41
+ .Some(p) => free(.Some(*(void)(p))),
42
+ .None => ()
43
+ );
44
+ })
45
+ )
46
+ );
47
+ impl(
48
+ String,
47
49
  /// Create a new empty string (zero allocation).
48
50
  new : (fn() -> Self)(
49
- Self(_ptr: .None, _len: usize(0), _capacity: usize(0))
51
+ Self(_ptr :.None, _len : usize(0), _capacity : usize(0))
50
52
  ),
51
-
52
53
  /// Create a string from a `str` slice (copies the bytes).
53
- from : (fn(s: str) -> Self)({
54
+ from : (fn(s : str) -> Self)({
54
55
  slen := s.len();
55
- if((slen == usize(0)), {
56
- return Self(_ptr: .None, _len: usize(0), _capacity: usize(0));
56
+ if(slen == usize(0), {
57
+ return(Self(_ptr :.None, _len : usize(0), _capacity : usize(0)));
57
58
  });
58
59
  ptr := _alloc_bytes(slen);
59
60
  memcpy(*(void)(ptr), *(void)(s.ptr()), slen);
60
- return Self(_ptr: .Some(ptr), _len: slen, _capacity: slen);
61
+ return(Self(_ptr :.Some(ptr), _len : slen, _capacity : slen));
61
62
  }),
62
-
63
63
  /// Create a string from a standard (mutable) String by copying its bytes.
64
- from_string : (fn(s: std_string.String) -> Self)({
64
+ from_string : (fn(s : std_string.String) -> Self)({
65
65
  slen := s.bytes_len();
66
- if((slen == usize(0)), {
67
- return Self(_ptr: .None, _len: usize(0), _capacity: usize(0));
66
+ if(slen == usize(0), {
67
+ return(Self(_ptr :.None, _len : usize(0), _capacity : usize(0)));
68
68
  });
69
69
  ptr := _alloc_bytes(slen);
70
70
  (as_str : str) = s.as_str();
71
71
  memcpy(*(void)(ptr), *(void)(as_str.ptr()), slen);
72
- return Self(_ptr: .Some(ptr), _len: slen, _capacity: slen);
72
+ return(Self(_ptr :.Some(ptr), _len : slen, _capacity : slen));
73
73
  }),
74
-
75
74
  /// Byte length of the string.
76
- bytes_len : (fn(self: Self) -> usize)(
75
+ bytes_len : (fn(self : Self) -> usize)(
77
76
  self._len
78
77
  ),
79
-
80
78
  /// Number of Unicode characters (runes) in the string.
81
- len : (fn(self: Self) -> usize)({
82
- if((self._len == usize(0)), {
83
- return usize(0);
79
+ len : (fn(self : Self) -> usize)({
80
+ if(self._len == usize(0), {
81
+ return(usize(0));
84
82
  });
85
83
  count := usize(0);
86
84
  i := usize(0);
87
- match(self._ptr,
85
+ match(
86
+ self._ptr,
88
87
  .None => (),
89
88
  .Some(p) => {
90
- while (i < self._len), (i = (i + usize(1))), {
89
+ while(i < self._len, i = (i + usize(1)), {
91
90
  (b : u8) = (p &+ i).*;
92
- if(((b & u8(0xC0)) != u8(0x80)), {
91
+ if((b & u8(0xC0)) != u8(0x80), {
93
92
  count = (count + usize(1));
94
93
  });
95
- };
94
+ });
96
95
  }
97
96
  );
98
97
  count
99
98
  }),
100
-
101
99
  /// Check if the string is empty.
102
- is_empty : (fn(self: Self) -> bool)(
103
- (self._len == usize(0))
100
+ is_empty : (fn(self : Self) -> bool)(
101
+ self._len == usize(0)
104
102
  ),
105
-
106
103
  /// Get a `str` view of the string's bytes (zero-copy borrow).
107
- as_str : (fn(self: Self) -> str)(
108
- match(self._ptr,
104
+ as_str : (fn(self : Self) -> str)(
105
+ match(
106
+ self._ptr,
109
107
  .Some(p) => str.from_raw_parts(p, self._len),
110
108
  .None => str.from_raw_parts(*(u8)(""), usize(0))
111
109
  )
112
110
  ),
113
-
114
111
  /// Get the byte at a given index, or `.None` if out of bounds.
115
- byte_at : (fn(self: Self, index: usize) -> Option(u8))(
112
+ byte_at : (fn(self : Self, index : usize) -> Option(u8))(
116
113
  cond(
117
- (index >= self._len) => .None,
118
- true => match(self._ptr,
119
- .Some(p) => .Some((p &+ index).*),
120
- .None => .None
114
+ (index >= self._len) =>.None,
115
+ true => match(
116
+ self._ptr,
117
+ .Some(p) =>.Some((p &+ index).*),
118
+ .None =>.None
121
119
  )
122
120
  )
123
121
  ),
124
-
125
122
  /// Concatenate two strings, returning a new string.
126
123
  /// Uses COW: if this string has a unique reference and enough capacity,
127
124
  /// appends in-place.
128
- concat : (fn(own(self): Self, other: Self) -> Self)({
129
- if((self._len == usize(0)), {
125
+ concat : (fn(own(self) : Self, other : Self) -> Self)({
126
+ if(self._len == usize(0), {
130
127
  unsafe.drop(self);
131
- return other;
128
+ return(other);
132
129
  });
133
- if((other._len == usize(0)), {
134
- return self;
130
+ if(other._len == usize(0), {
131
+ return(self);
135
132
  });
136
133
  new_len := (self._len + other._len);
137
- if((rc(self) == usize(1)), {
138
- if((new_len <= self._capacity), {
139
- match(other._ptr,
140
- .Some(op) => match(self._ptr,
141
- .Some(sp) => { memcpy(*(void)((sp &+ self._len)), *(void)(op), other._len); },
134
+ if(rc(self) == usize(1), {
135
+ if(new_len <= self._capacity, {
136
+ match(
137
+ other._ptr,
138
+ .Some(op) => match(
139
+ self._ptr,
140
+ .Some(sp) => {
141
+ memcpy(*(void)(sp &+ self._len), *(void)(op), other._len);
142
+ },
142
143
  .None => ()
143
144
  ),
144
145
  .None => ()
145
146
  );
146
147
  self._len = new_len;
147
- return self;
148
+ return(self);
148
149
  });
149
150
  new_cap := cond(
150
151
  (new_len > (self._capacity * usize(2))) => new_len,
151
152
  true => (self._capacity * usize(2))
152
153
  );
153
154
  ptr := _alloc_bytes(new_cap);
154
- match(self._ptr,
155
- .Some(sp) => { memcpy(*(void)(ptr), *(void)(sp), self._len); free(.Some(*(void)(sp))); },
155
+ match(
156
+ self._ptr,
157
+ .Some(sp) => {
158
+ memcpy(*(void)(ptr), *(void)(sp), self._len);
159
+ free(.Some(*(void)(sp)));
160
+ },
156
161
  .None => ()
157
162
  );
158
- match(other._ptr,
159
- .Some(op) => { memcpy(*(void)((ptr &+ self._len)), *(void)(op), other._len); },
163
+ match(
164
+ other._ptr,
165
+ .Some(op) => {
166
+ memcpy(*(void)(ptr &+ self._len), *(void)(op), other._len);
167
+ },
160
168
  .None => ()
161
169
  );
162
- self._ptr = .Some(ptr);
170
+ self._ptr =.Some(ptr);
163
171
  self._len = new_len;
164
172
  self._capacity = new_cap;
165
- return self;
173
+ return(self);
166
174
  });
167
175
  ptr := _alloc_bytes(new_len);
168
- match(self._ptr,
169
- .Some(sp) => { memcpy(*(void)(ptr), *(void)(sp), self._len); },
176
+ match(
177
+ self._ptr,
178
+ .Some(sp) => {
179
+ memcpy(*(void)(ptr), *(void)(sp), self._len);
180
+ },
170
181
  .None => ()
171
182
  );
172
- match(other._ptr,
173
- .Some(op) => { memcpy(*(void)((ptr &+ self._len)), *(void)(op), other._len); },
183
+ match(
184
+ other._ptr,
185
+ .Some(op) => {
186
+ memcpy(*(void)(ptr &+ self._len), *(void)(op), other._len);
187
+ },
174
188
  .None => ()
175
189
  );
176
190
  unsafe.drop(self);
177
- return Self(_ptr: .Some(ptr), _len: new_len, _capacity: new_len);
191
+ return(Self(_ptr :.Some(ptr), _len : new_len, _capacity : new_len));
178
192
  }),
179
-
180
193
  /// Extract a byte-range substring [start, end). Returns a new string.
181
194
  /// If indices are out of bounds, clamps to valid range.
182
- slice : (fn(self: Self, start: usize, end: usize) -> Self)({
195
+ slice : (fn(self : Self, start : usize, end : usize) -> Self)({
183
196
  (clamped_start : usize) = _min(start, self._len);
184
197
  (clamped_end : usize) = _min(end, self._len);
185
- if((clamped_start >= clamped_end), {
186
- return Self.new();
198
+ if(clamped_start >= clamped_end, {
199
+ return(Self.new());
187
200
  });
188
201
  new_len := (clamped_end - clamped_start);
189
202
  ptr := _alloc_bytes(new_len);
190
- match(self._ptr,
191
- .Some(sp) => { memcpy(*(void)(ptr), *(void)((sp &+ clamped_start)), new_len); },
203
+ match(
204
+ self._ptr,
205
+ .Some(sp) => {
206
+ memcpy(*(void)(ptr), *(void)(sp &+ clamped_start), new_len);
207
+ },
192
208
  .None => ()
193
209
  );
194
- return Self(_ptr: .Some(ptr), _len: new_len, _capacity: new_len);
210
+ return(Self(_ptr :.Some(ptr), _len : new_len, _capacity : new_len));
195
211
  }),
196
-
197
212
  /// Check if the string starts with a given prefix.
198
- starts_with : (fn(self: Self, prefix: Self) -> bool)({
199
- if((prefix._len > self._len), {
200
- return false;
213
+ starts_with : (fn(self : Self, prefix : Self) -> bool)({
214
+ if(prefix._len > self._len, {
215
+ return(false);
201
216
  });
202
- if((prefix._len == usize(0)), {
203
- return true;
217
+ if(prefix._len == usize(0), {
218
+ return(true);
204
219
  });
205
- match(self._ptr,
206
- .Some(sp) => match(prefix._ptr,
220
+ match(
221
+ self._ptr,
222
+ .Some(sp) => match(
223
+ prefix._ptr,
207
224
  .Some(pp) => (memcmp(*(void)(sp), *(void)(pp), prefix._len) == int(0)),
208
225
  .None => true
209
226
  ),
210
227
  .None => (prefix._len == usize(0))
211
228
  )
212
229
  }),
213
-
214
230
  /// Check if the string ends with a given suffix.
215
- ends_with : (fn(self: Self, suffix: Self) -> bool)({
216
- if((suffix._len > self._len), {
217
- return false;
231
+ ends_with : (fn(self : Self, suffix : Self) -> bool)({
232
+ if(suffix._len > self._len, {
233
+ return(false);
218
234
  });
219
- if((suffix._len == usize(0)), {
220
- return true;
235
+ if(suffix._len == usize(0), {
236
+ return(true);
221
237
  });
222
238
  offset := (self._len - suffix._len);
223
- match(self._ptr,
224
- .Some(sp) => match(suffix._ptr,
225
- .Some(xp) => (memcmp(*(void)((sp &+ offset)), *(void)(xp), suffix._len) == int(0)),
239
+ match(
240
+ self._ptr,
241
+ .Some(sp) => match(
242
+ suffix._ptr,
243
+ .Some(xp) => (memcmp(*(void)(sp &+ offset), *(void)(xp), suffix._len) == int(0)),
226
244
  .None => true
227
245
  ),
228
246
  .None => (suffix._len == usize(0))
229
247
  )
230
248
  }),
231
-
232
249
  /// Find the first occurrence of `needle` starting at `from_index`.
233
250
  /// Returns byte index or `.None`.
234
- index_of : (fn(self: Self, needle: Self, from_index: usize) -> Option(usize))({
235
- if((needle._len == usize(0)), {
236
- return .Some(from_index);
251
+ index_of : (fn(self : Self, needle : Self, from_index : usize) -> Option(usize))({
252
+ if(needle._len == usize(0), {
253
+ return(.Some(from_index));
237
254
  });
238
- if(((from_index + needle._len) > self._len), {
239
- return .None;
255
+ if((from_index + needle._len) > self._len, {
256
+ return(.None);
240
257
  });
241
- match(self._ptr,
242
- .None => { return .None; },
243
- .Some(sp) => match(needle._ptr,
244
- .None => { return .Some(from_index); },
258
+ match(
259
+ self._ptr,
260
+ .None => {
261
+ return(.None);
262
+ },
263
+ .Some(sp) => match(
264
+ needle._ptr,
265
+ .None => {
266
+ return(.Some(from_index));
267
+ },
245
268
  .Some(np) => {
246
269
  i := from_index;
247
270
  limit := ((self._len - needle._len) + usize(1));
248
- while (i < limit), (i = (i + usize(1))), {
249
- if((memcmp(*(void)((sp &+ i)), *(void)(np), needle._len) == int(0)), {
250
- return .Some(i);
271
+ while(i < limit, i = (i + usize(1)), {
272
+ if(memcmp(*(void)(sp &+ i), *(void)(np), needle._len) == int(0), {
273
+ return(.Some(i));
251
274
  });
252
- };
253
- return .None;
275
+ });
276
+ return(.None);
254
277
  }
255
278
  )
256
279
  )
257
280
  }),
258
-
259
281
  /// Check if the string contains a given substring.
260
- contains : (fn(self: Self, needle: Self) -> bool)(
282
+ contains : (fn(self : Self, needle : Self) -> bool)(
261
283
  self.index_of(needle, usize(0)).is_some()
262
284
  ),
263
-
264
285
  /// Split the string by a separator, returning an immutable List of Strings.
265
- split : (fn(self: Self, sep: Self) -> imm_list.List(String))({
286
+ split : (fn(self : Self, sep : Self) -> imm_list.List(String))({
266
287
  result := imm_list.List(String).new();
267
- if((sep._len == usize(0)), {
268
- return result.prepend(self);
288
+ if(sep._len == usize(0), {
289
+ return(result.prepend(self));
269
290
  });
270
291
  pos := usize(0);
271
292
  segments := imm_list.List(String).new();
272
- while runtime(true), {
273
- match(self.index_of(sep, pos),
293
+ while(runtime(true), {
294
+ match(
295
+ self.index_of(sep, pos),
274
296
  .Some(idx) => {
275
297
  segments = segments.prepend(self.slice(pos, idx));
276
298
  pos = (idx + sep._len);
277
299
  },
278
300
  .None => {
279
301
  segments = segments.prepend(self.slice(pos, self._len));
280
- return segments.reverse();
302
+ return(segments.reverse());
281
303
  }
282
304
  );
283
- };
305
+ });
284
306
  segments.reverse()
285
307
  }),
286
-
287
308
  /// Check if a byte is ASCII whitespace.
288
- _is_whitespace : (fn(b: u8) -> bool)(
289
- ((((b == u8(0x20)) || (b == u8(0x09))) || (b == u8(0x0A))) || ((b == u8(0x0D)) || (b == u8(0x0C))))
309
+ _is_whitespace : (fn(b : u8) -> bool)(
310
+ (((b == u8(0x20)) || (b == u8(0x09))) || (b == u8(0x0A))) || ((b == u8(0x0D)) || (b == u8(0x0C)))
290
311
  ),
291
-
292
312
  /// Trim leading and trailing ASCII whitespace.
293
- trim : (fn(self: Self) -> Self)({
294
- if((self._len == usize(0)), {
295
- return self;
313
+ trim : (fn(self : Self) -> Self)({
314
+ if(self._len == usize(0), {
315
+ return(self);
296
316
  });
297
- match(self._ptr,
298
- .None => { return self; },
317
+ match(
318
+ self._ptr,
319
+ .None => {
320
+ return(self);
321
+ },
299
322
  .Some(p) => {
300
323
  start := usize(0);
301
- while ((start < self._len) && (Self._is_whitespace((p &+ start).*))),
302
- (start = (start + usize(1))),
303
- ();
324
+ while(
325
+ (start < self._len) && (Self._is_whitespace((p &+ start).*)),
326
+ start = (start + usize(1)),
327
+ ()
328
+ );
304
329
  end := self._len;
305
- while ((end > start) && (Self._is_whitespace((p &+ (end - usize(1))).*))),
306
- (end = (end - usize(1))),
307
- ();
308
- if(((start == usize(0)) && (end == self._len)), {
309
- return self;
330
+ while(
331
+ (end > start) && (Self._is_whitespace((p &+ (end - usize(1))).*)),
332
+ end = (end - usize(1)),
333
+ ()
334
+ );
335
+ if((start == usize(0)) && (end == self._len), {
336
+ return(self);
310
337
  });
311
- return self.slice(start, end);
338
+ return(self.slice(start, end));
312
339
  }
313
340
  )
314
341
  }),
315
-
316
342
  /// Trim leading ASCII whitespace.
317
- trim_start : (fn(self: Self) -> Self)({
318
- if((self._len == usize(0)), {
319
- return self;
343
+ trim_start : (fn(self : Self) -> Self)({
344
+ if(self._len == usize(0), {
345
+ return(self);
320
346
  });
321
- match(self._ptr,
322
- .None => { return self; },
347
+ match(
348
+ self._ptr,
349
+ .None => {
350
+ return(self);
351
+ },
323
352
  .Some(p) => {
324
353
  start := usize(0);
325
- while ((start < self._len) && (Self._is_whitespace((p &+ start).*))),
326
- (start = (start + usize(1))),
327
- ();
328
- if((start == usize(0)), {
329
- return self;
354
+ while(
355
+ (start < self._len) && (Self._is_whitespace((p &+ start).*)),
356
+ start = (start + usize(1)),
357
+ ()
358
+ );
359
+ if(start == usize(0), {
360
+ return(self);
330
361
  });
331
- return self.slice(start, self._len);
362
+ return(self.slice(start, self._len));
332
363
  }
333
364
  )
334
365
  }),
335
-
336
366
  /// Trim trailing ASCII whitespace.
337
- trim_end : (fn(self: Self) -> Self)({
338
- if((self._len == usize(0)), {
339
- return self;
367
+ trim_end : (fn(self : Self) -> Self)({
368
+ if(self._len == usize(0), {
369
+ return(self);
340
370
  });
341
- match(self._ptr,
342
- .None => { return self; },
371
+ match(
372
+ self._ptr,
373
+ .None => {
374
+ return(self);
375
+ },
343
376
  .Some(p) => {
344
377
  end := self._len;
345
- while ((end > usize(0)) && (Self._is_whitespace((p &+ (end - usize(1))).*))),
346
- (end = (end - usize(1))),
347
- ();
348
- if((end == self._len), {
349
- return self;
378
+ while(
379
+ (end > usize(0)) && (Self._is_whitespace((p &+ (end - usize(1))).*)),
380
+ end = (end - usize(1)),
381
+ ()
382
+ );
383
+ if(end == self._len, {
384
+ return(self);
350
385
  });
351
- return self.slice(usize(0), end);
386
+ return(self.slice(usize(0), end));
352
387
  }
353
388
  )
354
389
  }),
355
-
356
390
  /// Convert all ASCII uppercase letters to lowercase.
357
391
  /// Uses COW: if this string has a unique reference, modifies bytes in-place.
358
- to_lowercase : (fn(own(self): Self) -> Self)({
359
- if((self._len == usize(0)), {
360
- return self;
392
+ to_lowercase : (fn(own(self) : Self) -> Self)({
393
+ if(self._len == usize(0), {
394
+ return(self);
361
395
  });
362
- match(self._ptr,
363
- .None => { return self; },
396
+ match(
397
+ self._ptr,
398
+ .None => {
399
+ return(self);
400
+ },
364
401
  .Some(sp) => {
365
- if((rc(self) == usize(1)), {
402
+ if(rc(self) == usize(1), {
366
403
  i := usize(0);
367
- while (i < self._len), (i = (i + usize(1))), {
404
+ while(i < self._len, i = (i + usize(1)), {
368
405
  (b : u8) = (sp &+ i).*;
369
- if(((b >= u8(0x41)) && (b <= u8(0x5A))), {
406
+ if((b >= u8(0x41)) && (b <= u8(0x5A)), {
370
407
  (sp &+ i).* = (b + u8(32));
371
408
  });
372
- };
373
- return self;
409
+ });
410
+ return(self);
374
411
  });
375
412
  ptr := _alloc_bytes(self._len);
376
413
  memcpy(*(void)(ptr), *(void)(sp), self._len);
377
414
  i := usize(0);
378
- while (i < self._len), (i = (i + usize(1))), {
415
+ while(i < self._len, i = (i + usize(1)), {
379
416
  (b : u8) = (ptr &+ i).*;
380
- if(((b >= u8(0x41)) && (b <= u8(0x5A))), {
417
+ if((b >= u8(0x41)) && (b <= u8(0x5A)), {
381
418
  (ptr &+ i).* = (b + u8(32));
382
419
  });
383
- };
420
+ });
384
421
  saved_len := self._len;
385
422
  unsafe.drop(self);
386
- return Self(_ptr: .Some(ptr), _len: saved_len, _capacity: saved_len);
423
+ return(Self(_ptr :.Some(ptr), _len : saved_len, _capacity : saved_len));
387
424
  }
388
425
  )
389
426
  }),
390
-
391
427
  /// Convert all ASCII lowercase letters to uppercase.
392
428
  /// Uses COW: if this string has a unique reference, modifies bytes in-place.
393
- to_uppercase : (fn(own(self): Self) -> Self)({
394
- if((self._len == usize(0)), {
395
- return self;
429
+ to_uppercase : (fn(own(self) : Self) -> Self)({
430
+ if(self._len == usize(0), {
431
+ return(self);
396
432
  });
397
- match(self._ptr,
398
- .None => { return self; },
433
+ match(
434
+ self._ptr,
435
+ .None => {
436
+ return(self);
437
+ },
399
438
  .Some(sp) => {
400
- if((rc(self) == usize(1)), {
439
+ if(rc(self) == usize(1), {
401
440
  i := usize(0);
402
- while (i < self._len), (i = (i + usize(1))), {
441
+ while(i < self._len, i = (i + usize(1)), {
403
442
  (b : u8) = (sp &+ i).*;
404
- if(((b >= u8(0x61)) && (b <= u8(0x7A))), {
443
+ if((b >= u8(0x61)) && (b <= u8(0x7A)), {
405
444
  (sp &+ i).* = (b - u8(32));
406
445
  });
407
- };
408
- return self;
446
+ });
447
+ return(self);
409
448
  });
410
449
  ptr := _alloc_bytes(self._len);
411
450
  memcpy(*(void)(ptr), *(void)(sp), self._len);
412
451
  i := usize(0);
413
- while (i < self._len), (i = (i + usize(1))), {
452
+ while(i < self._len, i = (i + usize(1)), {
414
453
  (b : u8) = (ptr &+ i).*;
415
- if(((b >= u8(0x61)) && (b <= u8(0x7A))), {
454
+ if((b >= u8(0x61)) && (b <= u8(0x7A)), {
416
455
  (ptr &+ i).* = (b - u8(32));
417
456
  });
418
- };
457
+ });
419
458
  saved_len := self._len;
420
459
  unsafe.drop(self);
421
- return Self(_ptr: .Some(ptr), _len: saved_len, _capacity: saved_len);
460
+ return(Self(_ptr :.Some(ptr), _len : saved_len, _capacity : saved_len));
422
461
  }
423
462
  )
424
463
  }),
425
-
426
464
  /// Replace the first occurrence of `search` with `replacement`.
427
- replace : (fn(self: Self, search: Self, replacement: Self) -> Self)(
428
- match(self.index_of(search, usize(0)),
429
- .None => { return self; },
465
+ replace : (fn(self : Self, search : Self, replacement : Self) -> Self)(
466
+ match(
467
+ self.index_of(search, usize(0)),
468
+ .None => {
469
+ return(self);
470
+ },
430
471
  .Some(idx) => {
431
472
  before := self.slice(usize(0), idx);
432
- after := self.slice((idx + search._len), self._len);
473
+ after := self.slice(idx + search._len, self._len);
433
474
  tmp := before.concat(replacement);
434
- return tmp.concat(after);
475
+ return(tmp.concat(after));
435
476
  }
436
477
  )
437
478
  ),
438
-
439
479
  /// Replace all occurrences of `search` with `replacement`.
440
- replace_all : (fn(self: Self, search: Self, replacement: Self) -> Self)({
441
- if((search._len == usize(0)), {
442
- return self;
480
+ replace_all : (fn(self : Self, search : Self, replacement : Self) -> Self)({
481
+ if(search._len == usize(0), {
482
+ return(self);
443
483
  });
444
484
  result := Self.new();
445
485
  pos := usize(0);
446
486
  done := false;
447
- while (!(done)), {
448
- match(self.index_of(search, pos),
487
+ while(!(done), {
488
+ match(
489
+ self.index_of(search, pos),
449
490
  .Some(idx) => {
450
491
  segment := self.slice(pos, idx);
451
492
  result = result.concat(segment);
@@ -457,89 +498,93 @@ impl(String,
457
498
  done = true;
458
499
  }
459
500
  );
460
- };
501
+ });
461
502
  result
462
503
  }),
463
-
464
504
  /// Repeat the string `n` times.
465
- repeat : (fn(self: Self, n: usize) -> Self)({
466
- if(((n == usize(0)) || (self._len == usize(0))), {
467
- return Self.new();
505
+ repeat : (fn(self : Self, n : usize) -> Self)({
506
+ if((n == usize(0)) || (self._len == usize(0)), {
507
+ return(Self.new());
468
508
  });
469
- if((n == usize(1)), {
470
- return self;
509
+ if(n == usize(1), {
510
+ return(self);
471
511
  });
472
512
  new_len := (self._len * n);
473
513
  ptr := _alloc_bytes(new_len);
474
- match(self._ptr,
514
+ match(
515
+ self._ptr,
475
516
  .Some(sp) => {
476
517
  i := usize(0);
477
- while (i < n), (i = (i + usize(1))), {
478
- memcpy(*(void)((ptr &+ (i * self._len))), *(void)(sp), self._len);
479
- };
518
+ while(i < n, i = (i + usize(1)), {
519
+ memcpy(*(void)(ptr &+ (i * self._len)), *(void)(sp), self._len);
520
+ });
480
521
  },
481
522
  .None => ()
482
523
  );
483
- return Self(_ptr: .Some(ptr), _len: new_len, _capacity: new_len);
524
+ return(Self(_ptr :.Some(ptr), _len : new_len, _capacity : new_len));
484
525
  }),
485
-
486
526
  /// Decode a single UTF-8 rune starting at byte index.
487
- _decode_rune_at : (fn(self: Self, byte_index: usize) -> Option(rune))({
488
- if((byte_index >= self._len), {
489
- return .None;
527
+ _decode_rune_at : (fn(self : Self, byte_index : usize) -> Option(rune))({
528
+ if(byte_index >= self._len, {
529
+ return(.None);
490
530
  });
491
- match(self._ptr,
492
- .None => { return .None; },
531
+ match(
532
+ self._ptr,
533
+ .None => {
534
+ return(.None);
535
+ },
493
536
  .Some(p) => {
494
537
  (b0 : u8) = (p &+ byte_index).*;
495
- if(((b0 & u8(0x80)) == u8(0)), {
496
- return .Some(rune(char: u32(b0)));
538
+ if((b0 & u8(0x80)) == u8(0), {
539
+ return(.Some(rune(char : u32(b0))));
497
540
  });
498
- if(((b0 & u8(0xE0)) == u8(0xC0)), {
499
- if(((byte_index + usize(1)) >= self._len), {
500
- return .None;
541
+ if((b0 & u8(0xE0)) == u8(0xC0), {
542
+ if((byte_index + usize(1)) >= self._len, {
543
+ return(.None);
501
544
  });
502
545
  (b1 : u8) = (p &+ (byte_index + usize(1))).*;
503
546
  (code : u32) = (((u32(b0) & u32(0x1F)) << u32(6)) | (u32(b1) & u32(0x3F)));
504
- return .Some(rune(char: code));
547
+ return(.Some(rune(char : code)));
505
548
  });
506
- if(((b0 & u8(0xF0)) == u8(0xE0)), {
507
- if(((byte_index + usize(2)) >= self._len), {
508
- return .None;
549
+ if((b0 & u8(0xF0)) == u8(0xE0), {
550
+ if((byte_index + usize(2)) >= self._len, {
551
+ return(.None);
509
552
  });
510
553
  (b1 : u8) = (p &+ (byte_index + usize(1))).*;
511
554
  (b2 : u8) = (p &+ (byte_index + usize(2))).*;
512
555
  (code : u32) = ((((u32(b0) & u32(0x0F)) << u32(12)) | ((u32(b1) & u32(0x3F)) << u32(6))) | (u32(b2) & u32(0x3F)));
513
- return .Some(rune(char: code));
556
+ return(.Some(rune(char : code)));
514
557
  });
515
- if(((b0 & u8(0xF8)) == u8(0xF0)), {
516
- if(((byte_index + usize(3)) >= self._len), {
517
- return .None;
558
+ if((b0 & u8(0xF8)) == u8(0xF0), {
559
+ if((byte_index + usize(3)) >= self._len, {
560
+ return(.None);
518
561
  });
519
562
  (b1 : u8) = (p &+ (byte_index + usize(1))).*;
520
563
  (b2 : u8) = (p &+ (byte_index + usize(2))).*;
521
564
  (b3 : u8) = (p &+ (byte_index + usize(3))).*;
522
565
  (code : u32) = (((((u32(b0) & u32(0x07)) << u32(18)) | ((u32(b1) & u32(0x3F)) << u32(12))) | ((u32(b2) & u32(0x3F)) << u32(6))) | (u32(b3) & u32(0x3F)));
523
- return .Some(rune(char: code));
566
+ return(.Some(rune(char : code)));
524
567
  });
525
- return .None;
568
+ return(.None);
526
569
  }
527
570
  )
528
571
  }),
529
-
530
572
  /// Get the Unicode character (rune) at a given character index.
531
- at : (fn(self: Self, index: usize) -> Option(rune))({
532
- if((self._len == usize(0)), {
533
- return .None;
573
+ at : (fn(self : Self, index : usize) -> Option(rune))({
574
+ if(self._len == usize(0), {
575
+ return(.None);
534
576
  });
535
- match(self._ptr,
536
- .None => { return .None; },
577
+ match(
578
+ self._ptr,
579
+ .None => {
580
+ return(.None);
581
+ },
537
582
  .Some(p) => {
538
583
  char_count := usize(0);
539
584
  byte_index := usize(0);
540
- while (byte_index < self._len), (), {
541
- if((char_count == index), {
542
- return self._decode_rune_at(byte_index);
585
+ while(byte_index < self._len, (), {
586
+ if(char_count == index, {
587
+ return(self._decode_rune_at(byte_index));
543
588
  });
544
589
  (b : u8) = (p &+ byte_index).*;
545
590
  cond(
@@ -557,111 +602,125 @@ impl(String,
557
602
  }
558
603
  );
559
604
  char_count = (char_count + usize(1));
560
- };
561
- return .None;
605
+ });
606
+ return(.None);
562
607
  }
563
608
  )
564
609
  })
565
610
  );
566
-
567
611
  /// Equality by byte content.
568
- impl(String, Eq(String)(
569
- (==) : (fn(self: Self, other: Self) -> bool)({
570
- if((self._len != other._len), {
571
- return false;
572
- });
573
- if((self._len == usize(0)), {
574
- return true;
575
- });
576
- match(self._ptr,
577
- .Some(sp) => match(other._ptr,
578
- .Some(op) => (memcmp(*(void)(sp), *(void)(op), self._len) == int(0)),
579
- .None => false
580
- ),
581
- .None => match(other._ptr,
582
- .Some(_) => false,
583
- .None => true
612
+ impl(
613
+ String,
614
+ Eq(String)(
615
+ (==) : (fn(self : Self, other : Self) -> bool)({
616
+ if(self._len != other._len, {
617
+ return(false);
618
+ });
619
+ if(self._len == usize(0), {
620
+ return(true);
621
+ });
622
+ match(
623
+ self._ptr,
624
+ .Some(sp) => match(
625
+ other._ptr,
626
+ .Some(op) => (memcmp(*(void)(sp), *(void)(op), self._len) == int(0)),
627
+ .None => false
628
+ ),
629
+ .None => match(
630
+ other._ptr,
631
+ .Some(_) => false,
632
+ .None => true
633
+ )
584
634
  )
585
- )
586
- }),
587
- (!=) : (fn(self: Self, other: Self) -> bool)({
588
- return !(Self.(==)(self, other));
589
- })
590
- ));
591
-
635
+ }),
636
+ (!=) : (fn(self : Self, other : Self) -> bool)({
637
+ return(!(Self.(==)(self, other)));
638
+ })
639
+ )
640
+ );
592
641
  // TODO: Eq(str) impl — "Variable str not found" inside impl blocks for atomic object types.
593
642
  // Provide eq_str method instead.
594
- impl(String,
643
+ impl(
644
+ String,
595
645
  /// Compare with a `str` for equality.
596
- eq_str : (fn(self: Self, other: str) -> bool)({
646
+ eq_str : (fn(self : Self, other : str) -> bool)({
597
647
  other_len := other.len();
598
- if((self._len != other_len), {
599
- return false;
648
+ if(self._len != other_len, {
649
+ return(false);
600
650
  });
601
- if((self._len == usize(0)), {
602
- return true;
651
+ if(self._len == usize(0), {
652
+ return(true);
603
653
  });
604
- match(self._ptr,
654
+ match(
655
+ self._ptr,
605
656
  .Some(sp) => (memcmp(*(void)(sp), *(void)(other.ptr()), self._len) == int(0)),
606
657
  .None => (other_len == usize(0))
607
658
  )
608
659
  })
609
660
  );
610
-
611
661
  /// Lexicographic ordering.
612
- impl(String, Ord(String)(
613
- (<) : (fn(self: Self, other: Self) -> bool)({
614
- min_len := _min(self._len, other._len);
615
- if((min_len > usize(0)), {
616
- match(self._ptr,
617
- .Some(sp) => match(other._ptr,
618
- .Some(op) => {
619
- (cmp_result : int) = memcmp(*(void)(sp), *(void)(op), min_len);
620
- if((cmp_result != int(0)), {
621
- return (cmp_result < int(0));
622
- });
623
- },
662
+ impl(
663
+ String,
664
+ Ord(String)(
665
+ (<) : (fn(self : Self, other : Self) -> bool)({
666
+ min_len := _min(self._len, other._len);
667
+ if(min_len > usize(0), {
668
+ match(
669
+ self._ptr,
670
+ .Some(sp) => match(
671
+ other._ptr,
672
+ .Some(op) => {
673
+ (cmp_result : int) = memcmp(*(void)(sp), *(void)(op), min_len);
674
+ if(cmp_result != int(0), {
675
+ return(cmp_result < int(0));
676
+ });
677
+ },
678
+ .None => ()
679
+ ),
624
680
  .None => ()
625
- ),
626
- .None => ()
627
- );
628
- });
629
- (self._len < other._len)
630
- }),
631
- (<=) : (fn(self: Self, other: Self) -> bool)({
632
- return !(other < self);
633
- }),
634
- (>) : (fn(self: Self, other: Self) -> bool)(
635
- (other < self)
636
- ),
637
- (>=) : (fn(self: Self, other: Self) -> bool)({
638
- return !(self < other);
639
- })
640
- ));
641
-
681
+ );
682
+ });
683
+ self._len < other._len
684
+ }),
685
+ (<=) : (fn(self : Self, other : Self) -> bool)({
686
+ return(!(other < self));
687
+ }),
688
+ (>) : (fn(self : Self, other : Self) -> bool)(
689
+ other < self
690
+ ),
691
+ (>=) : (fn(self : Self, other : Self) -> bool)({
692
+ return(!(self < other));
693
+ })
694
+ )
695
+ );
642
696
  /// FNV-1a hash over the string's bytes.
643
- impl(String, Hash(
644
- (hash) : (fn(self: *(Self)) -> u64)({
645
- h := u64(14695981039346656037);
646
- match(self.*._ptr,
647
- .None => (),
648
- .Some(p) => {
649
- i := usize(0);
650
- while (i < self.*._len), (i = (i + usize(1))), {
651
- h = (h ^ u64((p &+ i).*));
652
- h = (h * u64(1099511628211));
653
- };
654
- }
655
- );
656
- h
657
- })
658
- ));
659
-
697
+ impl(
698
+ String,
699
+ Hash(
700
+ (hash) : (fn(self : *(Self)) -> u64)({
701
+ h := u64(14695981039346656037);
702
+ match(
703
+ self.*._ptr,
704
+ .None => (),
705
+ .Some(p) => {
706
+ i := usize(0);
707
+ while(i < self.*._len, i = (i + usize(1)), {
708
+ h = (h ^ u64((p &+ i).*));
709
+ h = (h * u64(1099511628211));
710
+ });
711
+ }
712
+ );
713
+ h
714
+ })
715
+ )
716
+ );
660
717
  /// ToString returns a std.String for compatibility with println/print.
661
- impl(String, ToString(
662
- to_string : (fn(self: *(Self)) -> std_string.String)(
663
- std_string.String.from(self.*.as_str())
718
+ impl(
719
+ String,
720
+ ToString(
721
+ to_string : (fn(self : *(Self)) -> std_string.String)(
722
+ std_string.String.from(self.*.as_str())
723
+ )
664
724
  )
665
- ));
666
-
667
- export String;
725
+ );
726
+ export(String);