@grain/stdlib 0.7.0 → 0.7.2
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.
- package/CHANGELOG.md +18 -0
- package/array.md +491 -491
- package/bigint.md +198 -198
- package/buffer.gr +66 -1
- package/buffer.md +395 -272
- package/bytes.gr +1 -0
- package/bytes.md +200 -199
- package/char.md +125 -125
- package/exception.md +9 -9
- package/float32.md +195 -195
- package/float64.md +195 -195
- package/fs.md +115 -115
- package/hash.md +16 -16
- package/int16.md +155 -155
- package/int32.gr +1 -1
- package/int32.md +207 -207
- package/int64.gr +1 -1
- package/int64.md +207 -207
- package/int8.md +155 -155
- package/json.md +59 -59
- package/list.md +347 -347
- package/map.md +222 -222
- package/marshal.md +12 -12
- package/number.gr +119 -5
- package/number.md +503 -261
- package/option.md +141 -141
- package/package.json +2 -2
- package/path.gr +82 -65
- package/path.md +210 -141
- package/pervasives.md +238 -238
- package/priorityqueue.md +112 -112
- package/queue.md +117 -117
- package/random.md +37 -37
- package/range.md +36 -36
- package/rational.md +107 -107
- package/regex.md +91 -91
- package/result.md +102 -102
- package/runtime/atof/decimal.md +6 -6
- package/runtime/compare.md +7 -7
- package/runtime/dataStructures.md +178 -178
- package/runtime/equal.md +7 -7
- package/runtime/exception.md +15 -15
- package/runtime/malloc.md +9 -9
- package/runtime/numbers.md +269 -269
- package/runtime/string.md +17 -17
- package/runtime/unsafe/conv.md +6 -6
- package/runtime/unsafe/memory.gr +2 -19
- package/runtime/unsafe/memory.md +10 -10
- package/runtime/utf8.md +31 -31
- package/runtime/wasi.md +9 -9
- package/set.md +211 -211
- package/stack.md +122 -122
- package/string.md +228 -228
- package/uint16.md +148 -148
- package/uint32.md +192 -192
- package/uint64.md +192 -192
- package/uint8.md +148 -148
- package/uri.md +77 -77
- package/wasi/file.md +269 -269
- package/wasi/process.md +21 -21
- package/wasi/random.md +9 -9
- package/wasi/time.md +12 -12
package/regex.md
CHANGED
|
@@ -46,13 +46,13 @@ the following accessors:
|
|
|
46
46
|
|
|
47
47
|
Fields:
|
|
48
48
|
|
|
49
|
-
|name|type|description|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
| name | type | description |
|
|
50
|
+
| ------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
51
|
+
| `group` | `Number => Option<String>` | Returns the contents of the given group. Note that group 0 contains<br/>the entire matched substring, and group 1 contains the first parenthesized group. |
|
|
52
|
+
| `groupPosition` | `Number => Option<(Number, Number)>` | Returns the position of the given group |
|
|
53
|
+
| `numGroups` | `Number` | Returns the number of defined groups in this match object (includes group 0) |
|
|
54
|
+
| `allGroups` | `() => Array<Option<String>>` | Returns the contents of all groups matched in this match object |
|
|
55
|
+
| `allGroupPositions` | `() => Array<Option<(Number, Number)>>` | Returns the positions of all groups matched in this match object |
|
|
56
56
|
|
|
57
57
|
## Values
|
|
58
58
|
|
|
@@ -155,15 +155,15 @@ The *POSIX* classes are as follows:
|
|
|
155
155
|
|
|
156
156
|
Parameters:
|
|
157
157
|
|
|
158
|
-
|param|type|description|
|
|
159
|
-
|
|
160
|
-
|
|
158
|
+
| param | type | description |
|
|
159
|
+
| ------------- | -------- | --------------------------------- |
|
|
160
|
+
| `regexString` | `String` | The regular expression to compile |
|
|
161
161
|
|
|
162
162
|
Returns:
|
|
163
163
|
|
|
164
|
-
|type|description|
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
| type | description |
|
|
165
|
+
| ----------------------------------- | ------------------------------- |
|
|
166
|
+
| `Result<RegularExpression, String>` | The compiled regular expression |
|
|
167
167
|
|
|
168
168
|
Examples:
|
|
169
169
|
|
|
@@ -186,16 +186,16 @@ Determines if the given regular expression has a match in the given string.
|
|
|
186
186
|
|
|
187
187
|
Parameters:
|
|
188
188
|
|
|
189
|
-
|param|type|description|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
189
|
+
| param | type | description |
|
|
190
|
+
| -------- | ------------------- | ------------------------------------ |
|
|
191
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
192
|
+
| `string` | `String` | The string to search within |
|
|
193
193
|
|
|
194
194
|
Returns:
|
|
195
195
|
|
|
196
|
-
|type|description|
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
| type | description |
|
|
197
|
+
| ------ | ------------------------------------------------------------ |
|
|
198
|
+
| `Bool` | `true` if the RegExp matches the string or `false` otherwise |
|
|
199
199
|
|
|
200
200
|
Examples:
|
|
201
201
|
|
|
@@ -219,18 +219,18 @@ Determines if the given regular expression has a match in the given string betwe
|
|
|
219
219
|
|
|
220
220
|
Parameters:
|
|
221
221
|
|
|
222
|
-
|param|type|description|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
222
|
+
| param | type | description |
|
|
223
|
+
| -------- | ------------------- | ------------------------------------ |
|
|
224
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
225
|
+
| `string` | `String` | The string to search |
|
|
226
|
+
| `start` | `Number` | The start offset to search between |
|
|
227
|
+
| `end` | `Number` | The end offset to search between |
|
|
228
228
|
|
|
229
229
|
Returns:
|
|
230
230
|
|
|
231
|
-
|type|description|
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
| type | description |
|
|
232
|
+
| ------ | ----------------------------------------------------------------------------- |
|
|
233
|
+
| `Bool` | `true` if the RegExp matches the string in the given range, otherwise `false` |
|
|
234
234
|
|
|
235
235
|
Examples:
|
|
236
236
|
|
|
@@ -257,16 +257,16 @@ Returns the first match for the given regular expression contained within the gi
|
|
|
257
257
|
|
|
258
258
|
Parameters:
|
|
259
259
|
|
|
260
|
-
|param|type|description|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
| param | type | description |
|
|
261
|
+
| -------- | ------------------- | ------------------------------------ |
|
|
262
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
263
|
+
| `string` | `String` | The string to search |
|
|
264
264
|
|
|
265
265
|
Returns:
|
|
266
266
|
|
|
267
|
-
|type|description|
|
|
268
|
-
|
|
269
|
-
|
|
267
|
+
| type | description |
|
|
268
|
+
| --------------------- | ------------------------ |
|
|
269
|
+
| `Option<MatchResult>` | The match result, if any |
|
|
270
270
|
|
|
271
271
|
Examples:
|
|
272
272
|
|
|
@@ -292,18 +292,18 @@ between the given start/end range.
|
|
|
292
292
|
|
|
293
293
|
Parameters:
|
|
294
294
|
|
|
295
|
-
|param|type|description|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
295
|
+
| param | type | description |
|
|
296
|
+
| -------- | ------------------- | ------------------------------------ |
|
|
297
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
298
|
+
| `string` | `String` | The string to search |
|
|
299
|
+
| `start` | `Number` | The start offset to search between |
|
|
300
|
+
| `end` | `Number` | The end offset to search between |
|
|
301
301
|
|
|
302
302
|
Returns:
|
|
303
303
|
|
|
304
|
-
|type|description|
|
|
305
|
-
|
|
306
|
-
|
|
304
|
+
| type | description |
|
|
305
|
+
| --------------------- | ------------------------ |
|
|
306
|
+
| `Option<MatchResult>` | The match result, if any |
|
|
307
307
|
|
|
308
308
|
Examples:
|
|
309
309
|
|
|
@@ -321,16 +321,16 @@ Returns all matches for the given regular expression contained within the given
|
|
|
321
321
|
|
|
322
322
|
Parameters:
|
|
323
323
|
|
|
324
|
-
|param|type|description|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
324
|
+
| param | type | description |
|
|
325
|
+
| -------- | ------------------- | ------------------------------------ |
|
|
326
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
327
|
+
| `string` | `String` | The string to search |
|
|
328
328
|
|
|
329
329
|
Returns:
|
|
330
330
|
|
|
331
|
-
|type|description|
|
|
332
|
-
|
|
333
|
-
|
|
331
|
+
| type | description |
|
|
332
|
+
| ------------------- | ------------------- |
|
|
333
|
+
| `List<MatchResult>` | The list of matches |
|
|
334
334
|
|
|
335
335
|
### Regex.**findAllRange**
|
|
336
336
|
|
|
@@ -350,18 +350,18 @@ between the given start/end range.
|
|
|
350
350
|
|
|
351
351
|
Parameters:
|
|
352
352
|
|
|
353
|
-
|param|type|description|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
353
|
+
| param | type | description |
|
|
354
|
+
| -------- | ------------------- | ------------------------------------ |
|
|
355
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
356
|
+
| `string` | `String` | The string to search |
|
|
357
|
+
| `start` | `Number` | The start offset to search between |
|
|
358
|
+
| `end` | `Number` | The end offset to search between |
|
|
359
359
|
|
|
360
360
|
Returns:
|
|
361
361
|
|
|
362
|
-
|type|description|
|
|
363
|
-
|
|
364
|
-
|
|
362
|
+
| type | description |
|
|
363
|
+
| ------------------- | ------------------- |
|
|
364
|
+
| `List<MatchResult>` | The list of matches |
|
|
365
365
|
|
|
366
366
|
Examples:
|
|
367
367
|
|
|
@@ -393,17 +393,17 @@ Replacement strings support the following syntax:
|
|
|
393
393
|
|
|
394
394
|
Parameters:
|
|
395
395
|
|
|
396
|
-
|param|type|description|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
396
|
+
| param | type | description |
|
|
397
|
+
| ------------- | ------------------- | ------------------------------------ |
|
|
398
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
399
|
+
| `toSearch` | `String` | The string to search |
|
|
400
|
+
| `replacement` | `String` | The string that replaces matches |
|
|
401
401
|
|
|
402
402
|
Returns:
|
|
403
403
|
|
|
404
|
-
|type|description|
|
|
405
|
-
|
|
406
|
-
|
|
404
|
+
| type | description |
|
|
405
|
+
| -------- | ---------------------------------------------------------- |
|
|
406
|
+
| `String` | The given string with the appropriate replacements, if any |
|
|
407
407
|
|
|
408
408
|
Examples:
|
|
409
409
|
|
|
@@ -428,17 +428,17 @@ See `replace` for replacement string syntax.
|
|
|
428
428
|
|
|
429
429
|
Parameters:
|
|
430
430
|
|
|
431
|
-
|param|type|description|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
431
|
+
| param | type | description |
|
|
432
|
+
| ------------- | ------------------- | ------------------------------------ |
|
|
433
|
+
| `rx` | `RegularExpression` | The regular expression to search for |
|
|
434
|
+
| `toSearch` | `String` | The string to search |
|
|
435
|
+
| `replacement` | `String` | The string that replaces matches |
|
|
436
436
|
|
|
437
437
|
Returns:
|
|
438
438
|
|
|
439
|
-
|type|description|
|
|
440
|
-
|
|
441
|
-
|
|
439
|
+
| type | description |
|
|
440
|
+
| -------- | ---------------------------------------------------------- |
|
|
441
|
+
| `String` | The input string with the appropriate replacements, if any |
|
|
442
442
|
|
|
443
443
|
Examples:
|
|
444
444
|
|
|
@@ -464,16 +464,16 @@ will be included in the output list.
|
|
|
464
464
|
|
|
465
465
|
Parameters:
|
|
466
466
|
|
|
467
|
-
|param|type|description|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
467
|
+
| param | type | description |
|
|
468
|
+
| ----- | ------------------- | ------------------------------- |
|
|
469
|
+
| `rx` | `RegularExpression` | The regular expression to match |
|
|
470
|
+
| `str` | `String` | The string to split |
|
|
471
471
|
|
|
472
472
|
Returns:
|
|
473
473
|
|
|
474
|
-
|type|description|
|
|
475
|
-
|
|
476
|
-
|
|
474
|
+
| type | description |
|
|
475
|
+
| -------------- | ---------------------------- |
|
|
476
|
+
| `List<String>` | A list of the split segments |
|
|
477
477
|
|
|
478
478
|
Examples:
|
|
479
479
|
|
|
@@ -499,16 +499,16 @@ will be included in the output list.
|
|
|
499
499
|
|
|
500
500
|
Parameters:
|
|
501
501
|
|
|
502
|
-
|param|type|description|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
502
|
+
| param | type | description |
|
|
503
|
+
| ----- | ------------------- | ------------------------------- |
|
|
504
|
+
| `rx` | `RegularExpression` | The regular expression to match |
|
|
505
|
+
| `str` | `String` | The string to split |
|
|
506
506
|
|
|
507
507
|
Returns:
|
|
508
508
|
|
|
509
|
-
|type|description|
|
|
510
|
-
|
|
511
|
-
|
|
509
|
+
| type | description |
|
|
510
|
+
| -------------- | ---------------------------- |
|
|
511
|
+
| `List<String>` | A list of the split segments |
|
|
512
512
|
|
|
513
513
|
Examples:
|
|
514
514
|
|
package/result.md
CHANGED
|
@@ -43,15 +43,15 @@ Checks if the Result is the `Ok` variant.
|
|
|
43
43
|
|
|
44
44
|
Parameters:
|
|
45
45
|
|
|
46
|
-
|param|type|description|
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
| param | type | description |
|
|
47
|
+
| -------- | -------------- | ------------------- |
|
|
48
|
+
| `result` | `Result<a, b>` | The result to check |
|
|
49
49
|
|
|
50
50
|
Returns:
|
|
51
51
|
|
|
52
|
-
|type|description|
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
| type | description |
|
|
53
|
+
| ------ | ------------------------------------------------------------- |
|
|
54
|
+
| `Bool` | `true` if the Result is the `Ok` variant or `false` otherwise |
|
|
55
55
|
|
|
56
56
|
### Result.**isErr**
|
|
57
57
|
|
|
@@ -68,15 +68,15 @@ Checks if the Result is the `Err` variant.
|
|
|
68
68
|
|
|
69
69
|
Parameters:
|
|
70
70
|
|
|
71
|
-
|param|type|description|
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
| param | type | description |
|
|
72
|
+
| -------- | -------------- | ------------------- |
|
|
73
|
+
| `result` | `Result<a, b>` | The result to check |
|
|
74
74
|
|
|
75
75
|
Returns:
|
|
76
76
|
|
|
77
|
-
|type|description|
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
| type | description |
|
|
78
|
+
| ------ | -------------------------------------------------------------- |
|
|
79
|
+
| `Bool` | `true` if the Result is the `Err` variant or `false` otherwise |
|
|
80
80
|
|
|
81
81
|
### Result.**toOption**
|
|
82
82
|
|
|
@@ -93,15 +93,15 @@ Converts the Result to an Option. An error value is discarded and replaced with
|
|
|
93
93
|
|
|
94
94
|
Parameters:
|
|
95
95
|
|
|
96
|
-
|param|type|description|
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
| param | type | description |
|
|
97
|
+
| -------- | -------------- | --------------------- |
|
|
98
|
+
| `result` | `Result<a, b>` | The result to convert |
|
|
99
99
|
|
|
100
100
|
Returns:
|
|
101
101
|
|
|
102
|
-
|type|description|
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
| type | description |
|
|
103
|
+
| ----------- | ------------------------------------------------------------------------------ |
|
|
104
|
+
| `Option<a>` | `Some(value)` if the Result is `Ok(value)` or `None` if the Result is an `Err` |
|
|
105
105
|
|
|
106
106
|
### Result.**flatMap**
|
|
107
107
|
|
|
@@ -118,16 +118,16 @@ If the Result is `Ok(value)`, applies the given function to the `value` to produ
|
|
|
118
118
|
|
|
119
119
|
Parameters:
|
|
120
120
|
|
|
121
|
-
|param|type|description|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
| param | type | description |
|
|
122
|
+
| -------- | ------------------- | ---------------------------------------------------- |
|
|
123
|
+
| `fn` | `a => Result<b, c>` | The function to call on the value of an `Ok` variant |
|
|
124
|
+
| `result` | `Result<a, c>` | The result to map |
|
|
125
125
|
|
|
126
126
|
Returns:
|
|
127
127
|
|
|
128
|
-
|type|description|
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
| type | description |
|
|
129
|
+
| -------------- | ------------------------------------------------------------------------------------------------------- |
|
|
130
|
+
| `Result<b, c>` | A new Result produced by the mapping function if the variant was `Ok` or the unmodified `Err` otherwise |
|
|
131
131
|
|
|
132
132
|
### Result.**flatMapErr**
|
|
133
133
|
|
|
@@ -144,16 +144,16 @@ If the Result is an `Err(value)`, applies the given function to the `value` to p
|
|
|
144
144
|
|
|
145
145
|
Parameters:
|
|
146
146
|
|
|
147
|
-
|param|type|description|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
| param | type | description |
|
|
148
|
+
| -------- | ------------------- | ----------------------------------------------------- |
|
|
149
|
+
| `fn` | `a => Result<b, c>` | The function to call on the value of an `Err` variant |
|
|
150
|
+
| `result` | `Result<b, a>` | The result to map |
|
|
151
151
|
|
|
152
152
|
Returns:
|
|
153
153
|
|
|
154
|
-
|type|description|
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
| type | description |
|
|
155
|
+
| -------------- | ------------------------------------------------------------------------------------------------------- |
|
|
156
|
+
| `Result<b, c>` | A new Result produced by the mapping function if the variant was `Err` or the unmodified `Ok` otherwise |
|
|
157
157
|
|
|
158
158
|
### Result.**map**
|
|
159
159
|
|
|
@@ -170,16 +170,16 @@ If the Result is `Ok(value)`, applies the given function to the `value` and wrap
|
|
|
170
170
|
|
|
171
171
|
Parameters:
|
|
172
172
|
|
|
173
|
-
|param|type|description|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
173
|
+
| param | type | description |
|
|
174
|
+
| -------- | -------------- | ---------------------------------------------------- |
|
|
175
|
+
| `fn` | `a => b` | The function to call on the value of an `Ok` variant |
|
|
176
|
+
| `result` | `Result<a, c>` | The result to map |
|
|
177
177
|
|
|
178
178
|
Returns:
|
|
179
179
|
|
|
180
|
-
|type|description|
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
| type | description |
|
|
181
|
+
| -------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
182
|
+
| `Result<b, c>` | A new `Ok` variant produced by the mapping function if the variant was `Ok` or the unmodified `Err` otherwise |
|
|
183
183
|
|
|
184
184
|
### Result.**mapErr**
|
|
185
185
|
|
|
@@ -196,16 +196,16 @@ If the Result is `Err(value)`, applies the given function to the `value` and wra
|
|
|
196
196
|
|
|
197
197
|
Parameters:
|
|
198
198
|
|
|
199
|
-
|param|type|description|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
| param | type | description |
|
|
200
|
+
| -------- | -------------- | ----------------------------------------------------- |
|
|
201
|
+
| `fn` | `a => b` | The function to call on the value of an `Err` variant |
|
|
202
|
+
| `result` | `Result<c, a>` | The result to map |
|
|
203
203
|
|
|
204
204
|
Returns:
|
|
205
205
|
|
|
206
|
-
|type|description|
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
| type | description |
|
|
207
|
+
| -------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
208
|
+
| `Result<c, b>` | A new `Err` variant produced by the mapping function if the variant was `Err` or the unmodified `Ok` otherwise |
|
|
209
209
|
|
|
210
210
|
### Result.**mapWithDefault**
|
|
211
211
|
|
|
@@ -223,17 +223,17 @@ Useful for unwrapping a successful Result while providing a fallback for any err
|
|
|
223
223
|
|
|
224
224
|
Parameters:
|
|
225
225
|
|
|
226
|
-
|param|type|description|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
226
|
+
| param | type | description |
|
|
227
|
+
| -------- | -------------- | ---------------------------------------------------- |
|
|
228
|
+
| `fn` | `a => b` | The function to call on the value of an `Ok` variant |
|
|
229
|
+
| `def` | `b` | A fallback value for an `Err` variant |
|
|
230
|
+
| `result` | `Result<a, c>` | The result to map |
|
|
231
231
|
|
|
232
232
|
Returns:
|
|
233
233
|
|
|
234
|
-
|type|description|
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
| type | description |
|
|
235
|
+
| ---- | -------------------------------------------------------------------------------------------------------------- |
|
|
236
|
+
| `b` | The value produced by the mapping function if the result is of the `Ok` variant or the default value otherwise |
|
|
237
237
|
|
|
238
238
|
### Result.**mapWithDefaultFn**
|
|
239
239
|
|
|
@@ -253,17 +253,17 @@ Useful for unwrapping a Result into a value, whether it is successful or unsucce
|
|
|
253
253
|
|
|
254
254
|
Parameters:
|
|
255
255
|
|
|
256
|
-
|param|type|description|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
| param | type | description |
|
|
257
|
+
| -------- | -------------- | ----------------------------------------------------- |
|
|
258
|
+
| `fnOk` | `a => b` | The function to call on the value of an `Ok` variant |
|
|
259
|
+
| `fnErr` | `c => b` | The function to call on the value of an `Err` variant |
|
|
260
|
+
| `result` | `Result<a, c>` | The result to map |
|
|
261
261
|
|
|
262
262
|
Returns:
|
|
263
263
|
|
|
264
|
-
|type|description|
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
| type | description |
|
|
265
|
+
| ---- | -------------------------------------------------- |
|
|
266
|
+
| `b` | The value produced by one of the mapping functions |
|
|
267
267
|
|
|
268
268
|
### Result.**(||)**
|
|
269
269
|
|
|
@@ -287,16 +287,16 @@ Behaves like a logical OR (`||`) where the first Result is only returned if it i
|
|
|
287
287
|
|
|
288
288
|
Parameters:
|
|
289
289
|
|
|
290
|
-
|param|type|description|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
| param | type | description |
|
|
291
|
+
| --------- | -------------- | ----------------- |
|
|
292
|
+
| `result1` | `Result<a, b>` | The first result |
|
|
293
|
+
| `result2` | `Result<a, b>` | The second result |
|
|
294
294
|
|
|
295
295
|
Returns:
|
|
296
296
|
|
|
297
|
-
|type|description|
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
| type | description |
|
|
298
|
+
| -------------- | ------------------------------------------------------------------------- |
|
|
299
|
+
| `Result<a, b>` | The first Result if it is the `Ok` variant or the second Result otherwise |
|
|
300
300
|
|
|
301
301
|
### Result.**(&&)**
|
|
302
302
|
|
|
@@ -320,16 +320,16 @@ Behaves like a logical AND (`&&`) where the first Result is only returned if it
|
|
|
320
320
|
|
|
321
321
|
Parameters:
|
|
322
322
|
|
|
323
|
-
|param|type|description|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
323
|
+
| param | type | description |
|
|
324
|
+
| --------- | -------------- | ----------------- |
|
|
325
|
+
| `result1` | `Result<a, b>` | The first result |
|
|
326
|
+
| `result2` | `Result<a, b>` | The second result |
|
|
327
327
|
|
|
328
328
|
Returns:
|
|
329
329
|
|
|
330
|
-
|type|description|
|
|
331
|
-
|
|
332
|
-
|
|
330
|
+
| type | description |
|
|
331
|
+
| -------------- | ---------------------------------------------------------------------------- |
|
|
332
|
+
| `Result<a, b>` | The second Result if both are the `Ok` variant or the first Result otherwise |
|
|
333
333
|
|
|
334
334
|
### Result.**peek**
|
|
335
335
|
|
|
@@ -348,11 +348,11 @@ Useful for inspecting Results without changing anything.
|
|
|
348
348
|
|
|
349
349
|
Parameters:
|
|
350
350
|
|
|
351
|
-
|param|type|description|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
351
|
+
| param | type | description |
|
|
352
|
+
| -------- | -------------- | ----------------------------------------------------- |
|
|
353
|
+
| `fnOk` | `a => b` | The function to call on the value of an `Ok` variant |
|
|
354
|
+
| `fnErr` | `c => d` | The function to call on the value of an `Err` variant |
|
|
355
|
+
| `result` | `Result<a, c>` | The result to inspect |
|
|
356
356
|
|
|
357
357
|
### Result.**peekOk**
|
|
358
358
|
|
|
@@ -369,10 +369,10 @@ If the Result is `Ok(value)`, applies the given function to the `value` without
|
|
|
369
369
|
|
|
370
370
|
Parameters:
|
|
371
371
|
|
|
372
|
-
|param|type|description|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
372
|
+
| param | type | description |
|
|
373
|
+
| -------- | -------------- | ---------------------------------------------------- |
|
|
374
|
+
| `fn` | `a => b` | The function to call on the value of an `Ok` variant |
|
|
375
|
+
| `result` | `Result<a, c>` | The result to inspect |
|
|
376
376
|
|
|
377
377
|
### Result.**peekErr**
|
|
378
378
|
|
|
@@ -389,10 +389,10 @@ If the Result is `Err(value)`, applies the given function to the `value` without
|
|
|
389
389
|
|
|
390
390
|
Parameters:
|
|
391
391
|
|
|
392
|
-
|param|type|description|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
392
|
+
| param | type | description |
|
|
393
|
+
| -------- | -------------- | ----------------------------------------------------- |
|
|
394
|
+
| `fn` | `a => b` | The function to call on the value of an `Err` variant |
|
|
395
|
+
| `result` | `Result<c, a>` | The result to inspect |
|
|
396
396
|
|
|
397
397
|
### Result.**expect**
|
|
398
398
|
|
|
@@ -410,16 +410,16 @@ exception containing the message and contents of the `Err`.
|
|
|
410
410
|
|
|
411
411
|
Parameters:
|
|
412
412
|
|
|
413
|
-
|param|type|description|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
413
|
+
| param | type | description |
|
|
414
|
+
| -------- | -------------- | ------------------------------------------------------ |
|
|
415
|
+
| `msg` | `String` | The message to prepend if the result contains an `Err` |
|
|
416
|
+
| `result` | `Result<a, b>` | The result to extract a value from |
|
|
417
417
|
|
|
418
418
|
Returns:
|
|
419
419
|
|
|
420
|
-
|type|description|
|
|
421
|
-
|
|
422
|
-
|
|
420
|
+
| type | description |
|
|
421
|
+
| ---- | ----------------------------------------------------- |
|
|
422
|
+
| `a` | The unwrapped value if the Result is the `Ok` variant |
|
|
423
423
|
|
|
424
424
|
Throws:
|
|
425
425
|
|
|
@@ -449,15 +449,15 @@ exception containing a default message and contents of the `Err`.
|
|
|
449
449
|
|
|
450
450
|
Parameters:
|
|
451
451
|
|
|
452
|
-
|param|type|description|
|
|
453
|
-
|
|
454
|
-
|
|
452
|
+
| param | type | description |
|
|
453
|
+
| -------- | -------------- | ---------------------------------- |
|
|
454
|
+
| `result` | `Result<a, b>` | The result to extract a value from |
|
|
455
455
|
|
|
456
456
|
Returns:
|
|
457
457
|
|
|
458
|
-
|type|description|
|
|
459
|
-
|
|
460
|
-
|
|
458
|
+
| type | description |
|
|
459
|
+
| ---- | ----------------------------------------------------- |
|
|
460
|
+
| `a` | The unwrapped value if the result is the `Ok` variant |
|
|
461
461
|
|
|
462
462
|
Throws:
|
|
463
463
|
|