happy-rusty 1.1.0 → 1.1.1
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/README.cn.md +1 -1
- package/README.md +1 -1
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs.map +1 -1
- package/dist/types.d.ts +0 -2
- package/docs/{index.md → README.md} +4 -4
- package/docs/functions/Err.md +8 -8
- package/docs/functions/Ok.md +8 -8
- package/docs/functions/Some.md +8 -8
- package/docs/functions/promiseToResult.md +8 -8
- package/docs/interfaces/None.md +127 -127
- package/docs/interfaces/Option.md +113 -119
- package/docs/interfaces/Result.md +104 -110
- package/docs/type-aliases/AsyncIOResult.md +8 -8
- package/docs/type-aliases/AsyncOption.md +8 -8
- package/docs/type-aliases/AsyncResult.md +8 -8
- package/docs/type-aliases/IOResult.md +8 -8
- package/docs/variables/None.md +4 -4
- package/package.json +8 -8
- package/src/enum/prelude.ts +0 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
[**happy-rusty**](../
|
|
1
|
+
[**happy-rusty**](../README.md) • **Docs**
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[happy-rusty](../
|
|
5
|
+
[happy-rusty](../README.md) / Result
|
|
6
6
|
|
|
7
7
|
# Interface: Result\<T, E\>
|
|
8
8
|
|
|
@@ -18,19 +18,13 @@ pub enum Result<T, E> {
|
|
|
18
18
|
}
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
## Type
|
|
21
|
+
## Type Parameters
|
|
22
22
|
|
|
23
|
-
| Type
|
|
24
|
-
|
|
|
23
|
+
| Type Parameter | Description |
|
|
24
|
+
| ------ | ------ |
|
|
25
25
|
| `T` | The type of the value contained in a successful `Result`. |
|
|
26
26
|
| `E` | The type of the error contained in an unsuccessful `Result`. |
|
|
27
27
|
|
|
28
|
-
## Properties
|
|
29
|
-
|
|
30
|
-
| Property | Modifier | Type | Description |
|
|
31
|
-
| :------ | :------ | :------ | :------ |
|
|
32
|
-
| `[resultKindSymbol]` | `private` | `"Ok"` \| `"Err"` | Identify `Ok` or `Err`. |
|
|
33
|
-
|
|
34
28
|
## Methods
|
|
35
29
|
|
|
36
30
|
### and()
|
|
@@ -41,16 +35,16 @@ and<U>(other): Result<U, E>
|
|
|
41
35
|
|
|
42
36
|
Returns `this` if the result is `Err`, otherwise returns the passed `Result`.
|
|
43
37
|
|
|
44
|
-
#### Type
|
|
38
|
+
#### Type Parameters
|
|
45
39
|
|
|
46
|
-
| Type
|
|
47
|
-
|
|
|
40
|
+
| Type Parameter | Description |
|
|
41
|
+
| ------ | ------ |
|
|
48
42
|
| `U` | The type of the value in the other `Result`. |
|
|
49
43
|
|
|
50
44
|
#### Parameters
|
|
51
45
|
|
|
52
46
|
| Parameter | Type | Description |
|
|
53
|
-
|
|
|
47
|
+
| ------ | ------ | ------ |
|
|
54
48
|
| `other` | [`Result`](Result.md)\<`U`, `E`\> | The `Result` to return if `this` is `Ok`. |
|
|
55
49
|
|
|
56
50
|
#### Returns
|
|
@@ -59,9 +53,9 @@ Returns `this` if the result is `Err`, otherwise returns the passed `Result`.
|
|
|
59
53
|
|
|
60
54
|
The passed `Result` if `this` is `Ok`, otherwise returns `this` (which is `Err`).
|
|
61
55
|
|
|
62
|
-
####
|
|
56
|
+
#### Defined in
|
|
63
57
|
|
|
64
|
-
[
|
|
58
|
+
[prelude.ts:516](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L516)
|
|
65
59
|
|
|
66
60
|
***
|
|
67
61
|
|
|
@@ -73,16 +67,16 @@ andThen<U>(fn): Result<U, E>
|
|
|
73
67
|
|
|
74
68
|
Calls the provided function with the contained value if `this` is `Ok`, otherwise returns `this` as `Err`.
|
|
75
69
|
|
|
76
|
-
#### Type
|
|
70
|
+
#### Type Parameters
|
|
77
71
|
|
|
78
|
-
| Type
|
|
79
|
-
|
|
|
72
|
+
| Type Parameter | Description |
|
|
73
|
+
| ------ | ------ |
|
|
80
74
|
| `U` | The type of the value returned by the function. |
|
|
81
75
|
|
|
82
76
|
#### Parameters
|
|
83
77
|
|
|
84
78
|
| Parameter | Type | Description |
|
|
85
|
-
|
|
|
79
|
+
| ------ | ------ | ------ |
|
|
86
80
|
| `fn` | (`value`) => [`Result`](Result.md)\<`U`, `E`\> | A function that takes the `Ok` value and returns a `Result`. |
|
|
87
81
|
|
|
88
82
|
#### Returns
|
|
@@ -91,9 +85,9 @@ Calls the provided function with the contained value if `this` is `Ok`, otherwis
|
|
|
91
85
|
|
|
92
86
|
The result of `fn` if `this` is `Ok`, otherwise `this` as `Err`.
|
|
93
87
|
|
|
94
|
-
####
|
|
88
|
+
#### Defined in
|
|
95
89
|
|
|
96
|
-
[
|
|
90
|
+
[prelude.ts:532](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L532)
|
|
97
91
|
|
|
98
92
|
***
|
|
99
93
|
|
|
@@ -108,7 +102,7 @@ Tests whether `this` and `other` are both `Ok` containing equal values, or both
|
|
|
108
102
|
#### Parameters
|
|
109
103
|
|
|
110
104
|
| Parameter | Type | Description |
|
|
111
|
-
|
|
|
105
|
+
| ------ | ------ | ------ |
|
|
112
106
|
| `other` | [`Result`](Result.md)\<`T`, `E`\> | The other `Result` to compare with. |
|
|
113
107
|
|
|
114
108
|
#### Returns
|
|
@@ -117,9 +111,9 @@ Tests whether `this` and `other` are both `Ok` containing equal values, or both
|
|
|
117
111
|
|
|
118
112
|
`true` if `this` and `other` are both `Ok` with equal values, or both are `Err` with equal errors, otherwise `false`.
|
|
119
113
|
|
|
120
|
-
####
|
|
114
|
+
#### Defined in
|
|
121
115
|
|
|
122
|
-
[
|
|
116
|
+
[prelude.ts:567](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L567)
|
|
123
117
|
|
|
124
118
|
***
|
|
125
119
|
|
|
@@ -137,9 +131,9 @@ If the result is `Ok`, returns `None`.
|
|
|
137
131
|
|
|
138
132
|
[`Option`](Option.md)\<`E`\>
|
|
139
133
|
|
|
140
|
-
####
|
|
134
|
+
#### Defined in
|
|
141
135
|
|
|
142
|
-
[
|
|
136
|
+
[prelude.ts:440](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L440)
|
|
143
137
|
|
|
144
138
|
***
|
|
145
139
|
|
|
@@ -154,7 +148,7 @@ Returns the contained `Ok` value, with a provided error message if the result is
|
|
|
154
148
|
#### Parameters
|
|
155
149
|
|
|
156
150
|
| Parameter | Type | Description |
|
|
157
|
-
|
|
|
151
|
+
| ------ | ------ | ------ |
|
|
158
152
|
| `msg` | `string` | The error message to provide if the result is an `Err`. |
|
|
159
153
|
|
|
160
154
|
#### Returns
|
|
@@ -165,9 +159,9 @@ Returns the contained `Ok` value, with a provided error message if the result is
|
|
|
165
159
|
|
|
166
160
|
Throws an error with the provided message if the result is an `Err`.
|
|
167
161
|
|
|
168
|
-
####
|
|
162
|
+
#### Defined in
|
|
169
163
|
|
|
170
|
-
[
|
|
164
|
+
[prelude.ts:383](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L383)
|
|
171
165
|
|
|
172
166
|
***
|
|
173
167
|
|
|
@@ -182,7 +176,7 @@ Returns the contained `Err` value, with a provided error message if the result i
|
|
|
182
176
|
#### Parameters
|
|
183
177
|
|
|
184
178
|
| Parameter | Type | Description |
|
|
185
|
-
|
|
|
179
|
+
| ------ | ------ | ------ |
|
|
186
180
|
| `msg` | `string` | The error message to provide if the result is an `Ok`. |
|
|
187
181
|
|
|
188
182
|
#### Returns
|
|
@@ -193,9 +187,9 @@ Returns the contained `Err` value, with a provided error message if the result i
|
|
|
193
187
|
|
|
194
188
|
Throws an error with the provided message if the result is an `Ok`.
|
|
195
189
|
|
|
196
|
-
####
|
|
190
|
+
#### Defined in
|
|
197
191
|
|
|
198
|
-
[
|
|
192
|
+
[prelude.ts:412](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L412)
|
|
199
193
|
|
|
200
194
|
***
|
|
201
195
|
|
|
@@ -209,25 +203,25 @@ Converts from `Result<Result<T, E>, E>` to `Result<T, E>`.
|
|
|
209
203
|
If the result is `Ok(Ok(T))`, returns `Ok(T)`.
|
|
210
204
|
If the result is `Ok(Err(E))` or `Err(E)`, returns `Err(E)`.
|
|
211
205
|
|
|
212
|
-
#### Type
|
|
206
|
+
#### Type Parameters
|
|
213
207
|
|
|
214
|
-
| Type
|
|
215
|
-
|
|
|
208
|
+
| Type Parameter |
|
|
209
|
+
| ------ |
|
|
216
210
|
| `T` |
|
|
217
211
|
|
|
218
212
|
#### Parameters
|
|
219
213
|
|
|
220
214
|
| Parameter | Type |
|
|
221
|
-
|
|
|
215
|
+
| ------ | ------ |
|
|
222
216
|
| `this` | [`Result`](Result.md)\<[`Result`](Result.md)\<`T`, `E`\>, `E`\> |
|
|
223
217
|
|
|
224
218
|
#### Returns
|
|
225
219
|
|
|
226
220
|
[`Result`](Result.md)\<`T`, `E`\>
|
|
227
221
|
|
|
228
|
-
####
|
|
222
|
+
#### Defined in
|
|
229
223
|
|
|
230
|
-
[
|
|
224
|
+
[prelude.ts:500](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L500)
|
|
231
225
|
|
|
232
226
|
***
|
|
233
227
|
|
|
@@ -243,7 +237,7 @@ Does not modify the `Result`.
|
|
|
243
237
|
#### Parameters
|
|
244
238
|
|
|
245
239
|
| Parameter | Type | Description |
|
|
246
|
-
|
|
|
240
|
+
| ------ | ------ | ------ |
|
|
247
241
|
| `fn` | (`value`) => `void` | A function to call with the `Ok` value. |
|
|
248
242
|
|
|
249
243
|
#### Returns
|
|
@@ -252,9 +246,9 @@ Does not modify the `Result`.
|
|
|
252
246
|
|
|
253
247
|
`this`, unmodified.
|
|
254
248
|
|
|
255
|
-
####
|
|
249
|
+
#### Defined in
|
|
256
250
|
|
|
257
|
-
[
|
|
251
|
+
[prelude.ts:550](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L550)
|
|
258
252
|
|
|
259
253
|
***
|
|
260
254
|
|
|
@@ -270,7 +264,7 @@ Does not modify the `Result`.
|
|
|
270
264
|
#### Parameters
|
|
271
265
|
|
|
272
266
|
| Parameter | Type | Description |
|
|
273
|
-
|
|
|
267
|
+
| ------ | ------ | ------ |
|
|
274
268
|
| `fn` | (`error`) => `void` | A function to call with the `Err` value. |
|
|
275
269
|
|
|
276
270
|
#### Returns
|
|
@@ -279,9 +273,9 @@ Does not modify the `Result`.
|
|
|
279
273
|
|
|
280
274
|
`this`, unmodified.
|
|
281
275
|
|
|
282
|
-
####
|
|
276
|
+
#### Defined in
|
|
283
277
|
|
|
284
|
-
[
|
|
278
|
+
[prelude.ts:558](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L558)
|
|
285
279
|
|
|
286
280
|
***
|
|
287
281
|
|
|
@@ -297,9 +291,9 @@ Returns `true` if the result is `Err`.
|
|
|
297
291
|
|
|
298
292
|
`boolean`
|
|
299
293
|
|
|
300
|
-
####
|
|
294
|
+
#### Defined in
|
|
301
295
|
|
|
302
|
-
[
|
|
296
|
+
[prelude.ts:356](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L356)
|
|
303
297
|
|
|
304
298
|
***
|
|
305
299
|
|
|
@@ -314,16 +308,16 @@ Returns `true` if the result is `Err` and the provided predicate returns `true`
|
|
|
314
308
|
#### Parameters
|
|
315
309
|
|
|
316
310
|
| Parameter | Type | Description |
|
|
317
|
-
|
|
|
311
|
+
| ------ | ------ | ------ |
|
|
318
312
|
| `predicate` | (`error`) => `boolean` | A function that takes the `Err` value and returns a boolean. |
|
|
319
313
|
|
|
320
314
|
#### Returns
|
|
321
315
|
|
|
322
316
|
`boolean`
|
|
323
317
|
|
|
324
|
-
####
|
|
318
|
+
#### Defined in
|
|
325
319
|
|
|
326
|
-
[
|
|
320
|
+
[prelude.ts:368](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L368)
|
|
327
321
|
|
|
328
322
|
***
|
|
329
323
|
|
|
@@ -339,9 +333,9 @@ Returns `true` if the result is `Ok`.
|
|
|
339
333
|
|
|
340
334
|
`boolean`
|
|
341
335
|
|
|
342
|
-
####
|
|
336
|
+
#### Defined in
|
|
343
337
|
|
|
344
|
-
[
|
|
338
|
+
[prelude.ts:351](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L351)
|
|
345
339
|
|
|
346
340
|
***
|
|
347
341
|
|
|
@@ -356,16 +350,16 @@ Returns `true` if the result is `Ok` and the provided predicate returns `true` f
|
|
|
356
350
|
#### Parameters
|
|
357
351
|
|
|
358
352
|
| Parameter | Type | Description |
|
|
359
|
-
|
|
|
353
|
+
| ------ | ------ | ------ |
|
|
360
354
|
| `predicate` | (`value`) => `boolean` | A function that takes the `Ok` value and returns a boolean. |
|
|
361
355
|
|
|
362
356
|
#### Returns
|
|
363
357
|
|
|
364
358
|
`boolean`
|
|
365
359
|
|
|
366
|
-
####
|
|
360
|
+
#### Defined in
|
|
367
361
|
|
|
368
|
-
[
|
|
362
|
+
[prelude.ts:362](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L362)
|
|
369
363
|
|
|
370
364
|
***
|
|
371
365
|
|
|
@@ -378,25 +372,25 @@ map<U>(fn): Result<U, E>
|
|
|
378
372
|
Maps a `Result<T, E>` to `Result<U, E>` by applying a function to a contained `Ok` value,
|
|
379
373
|
leaving an `Err` value untouched.
|
|
380
374
|
|
|
381
|
-
#### Type
|
|
375
|
+
#### Type Parameters
|
|
382
376
|
|
|
383
|
-
| Type
|
|
384
|
-
|
|
|
377
|
+
| Type Parameter | Description |
|
|
378
|
+
| ------ | ------ |
|
|
385
379
|
| `U` | The type of the value returned by the map function. |
|
|
386
380
|
|
|
387
381
|
#### Parameters
|
|
388
382
|
|
|
389
383
|
| Parameter | Type | Description |
|
|
390
|
-
|
|
|
384
|
+
| ------ | ------ | ------ |
|
|
391
385
|
| `fn` | (`value`) => `U` | A function that takes the `Ok` value and returns a new value. |
|
|
392
386
|
|
|
393
387
|
#### Returns
|
|
394
388
|
|
|
395
389
|
[`Result`](Result.md)\<`U`, `E`\>
|
|
396
390
|
|
|
397
|
-
####
|
|
391
|
+
#### Defined in
|
|
398
392
|
|
|
399
|
-
[
|
|
393
|
+
[prelude.ts:461](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L461)
|
|
400
394
|
|
|
401
395
|
***
|
|
402
396
|
|
|
@@ -409,25 +403,25 @@ mapErr<F>(fn): Result<T, F>
|
|
|
409
403
|
Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a contained `Err` value,
|
|
410
404
|
leaving an `Ok` value untouched.
|
|
411
405
|
|
|
412
|
-
#### Type
|
|
406
|
+
#### Type Parameters
|
|
413
407
|
|
|
414
|
-
| Type
|
|
415
|
-
|
|
|
408
|
+
| Type Parameter | Description |
|
|
409
|
+
| ------ | ------ |
|
|
416
410
|
| `F` | The type of the error returned by the map function. |
|
|
417
411
|
|
|
418
412
|
#### Parameters
|
|
419
413
|
|
|
420
414
|
| Parameter | Type | Description |
|
|
421
|
-
|
|
|
415
|
+
| ------ | ------ | ------ |
|
|
422
416
|
| `fn` | (`error`) => `F` | A function that takes the `Err` value and returns a new error value. |
|
|
423
417
|
|
|
424
418
|
#### Returns
|
|
425
419
|
|
|
426
420
|
[`Result`](Result.md)\<`T`, `F`\>
|
|
427
421
|
|
|
428
|
-
####
|
|
422
|
+
#### Defined in
|
|
429
423
|
|
|
430
|
-
[
|
|
424
|
+
[prelude.ts:473](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L473)
|
|
431
425
|
|
|
432
426
|
***
|
|
433
427
|
|
|
@@ -439,16 +433,16 @@ mapOr<U>(defaultValue, fn): U
|
|
|
439
433
|
|
|
440
434
|
Maps a `Result<T, E>` to `U` by applying a function to the contained `Ok` value (if `Ok`), or returns the provided default (if `Err`).
|
|
441
435
|
|
|
442
|
-
#### Type
|
|
436
|
+
#### Type Parameters
|
|
443
437
|
|
|
444
|
-
| Type
|
|
445
|
-
|
|
|
438
|
+
| Type Parameter | Description |
|
|
439
|
+
| ------ | ------ |
|
|
446
440
|
| `U` | The type of the value returned by the map function or the default value. |
|
|
447
441
|
|
|
448
442
|
#### Parameters
|
|
449
443
|
|
|
450
444
|
| Parameter | Type | Description |
|
|
451
|
-
|
|
|
445
|
+
| ------ | ------ | ------ |
|
|
452
446
|
| `defaultValue` | `U` | The value to return if the result is `Err`. |
|
|
453
447
|
| `fn` | (`value`) => `U` | A function that takes the `Ok` value and returns a new value. |
|
|
454
448
|
|
|
@@ -456,9 +450,9 @@ Maps a `Result<T, E>` to `U` by applying a function to the contained `Ok` value
|
|
|
456
450
|
|
|
457
451
|
`U`
|
|
458
452
|
|
|
459
|
-
####
|
|
453
|
+
#### Defined in
|
|
460
454
|
|
|
461
|
-
[
|
|
455
|
+
[prelude.ts:485](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L485)
|
|
462
456
|
|
|
463
457
|
***
|
|
464
458
|
|
|
@@ -470,16 +464,16 @@ mapOrElse<U>(defaultFn, fn): U
|
|
|
470
464
|
|
|
471
465
|
Maps a `Result<T, E>` to `U` by applying a function to the contained `Ok` value (if `Ok`), or computes a default (if `Err`).
|
|
472
466
|
|
|
473
|
-
#### Type
|
|
467
|
+
#### Type Parameters
|
|
474
468
|
|
|
475
|
-
| Type
|
|
476
|
-
|
|
|
469
|
+
| Type Parameter | Description |
|
|
470
|
+
| ------ | ------ |
|
|
477
471
|
| `U` | The type of the value returned by the map function or the default function. |
|
|
478
472
|
|
|
479
473
|
#### Parameters
|
|
480
474
|
|
|
481
475
|
| Parameter | Type | Description |
|
|
482
|
-
|
|
|
476
|
+
| ------ | ------ | ------ |
|
|
483
477
|
| `defaultFn` | (`error`) => `U` | A function that returns the default value. |
|
|
484
478
|
| `fn` | (`value`) => `U` | A function that takes the `Ok` value and returns a new value. |
|
|
485
479
|
|
|
@@ -487,9 +481,9 @@ Maps a `Result<T, E>` to `U` by applying a function to the contained `Ok` value
|
|
|
487
481
|
|
|
488
482
|
`U`
|
|
489
483
|
|
|
490
|
-
####
|
|
484
|
+
#### Defined in
|
|
491
485
|
|
|
492
|
-
[
|
|
486
|
+
[prelude.ts:493](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L493)
|
|
493
487
|
|
|
494
488
|
***
|
|
495
489
|
|
|
@@ -507,9 +501,9 @@ If the result is `Err`, returns `None`.
|
|
|
507
501
|
|
|
508
502
|
[`Option`](Option.md)\<`T`\>
|
|
509
503
|
|
|
510
|
-
####
|
|
504
|
+
#### Defined in
|
|
511
505
|
|
|
512
|
-
[
|
|
506
|
+
[prelude.ts:433](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L433)
|
|
513
507
|
|
|
514
508
|
***
|
|
515
509
|
|
|
@@ -521,16 +515,16 @@ or<F>(other): Result<T, F>
|
|
|
521
515
|
|
|
522
516
|
Returns `this` if it is `Ok`, otherwise returns the passed `Result`.
|
|
523
517
|
|
|
524
|
-
#### Type
|
|
518
|
+
#### Type Parameters
|
|
525
519
|
|
|
526
|
-
| Type
|
|
527
|
-
|
|
|
520
|
+
| Type Parameter | Description |
|
|
521
|
+
| ------ | ------ |
|
|
528
522
|
| `F` | The type of the error in the other `Result`. |
|
|
529
523
|
|
|
530
524
|
#### Parameters
|
|
531
525
|
|
|
532
526
|
| Parameter | Type | Description |
|
|
533
|
-
|
|
|
527
|
+
| ------ | ------ | ------ |
|
|
534
528
|
| `other` | [`Result`](Result.md)\<`T`, `F`\> | The `Result` to return if `this` is `Err`. |
|
|
535
529
|
|
|
536
530
|
#### Returns
|
|
@@ -539,9 +533,9 @@ Returns `this` if it is `Ok`, otherwise returns the passed `Result`.
|
|
|
539
533
|
|
|
540
534
|
`this` if it is `Ok`, otherwise returns `other`.
|
|
541
535
|
|
|
542
|
-
####
|
|
536
|
+
#### Defined in
|
|
543
537
|
|
|
544
|
-
[
|
|
538
|
+
[prelude.ts:524](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L524)
|
|
545
539
|
|
|
546
540
|
***
|
|
547
541
|
|
|
@@ -553,16 +547,16 @@ orElse<F>(fn): Result<T, F>
|
|
|
553
547
|
|
|
554
548
|
Calls the provided function with the contained error if `this` is `Err`, otherwise returns `this` as `Ok`.
|
|
555
549
|
|
|
556
|
-
#### Type
|
|
550
|
+
#### Type Parameters
|
|
557
551
|
|
|
558
|
-
| Type
|
|
559
|
-
|
|
|
552
|
+
| Type Parameter | Description |
|
|
553
|
+
| ------ | ------ |
|
|
560
554
|
| `F` | The type of the error returned by the function. |
|
|
561
555
|
|
|
562
556
|
#### Parameters
|
|
563
557
|
|
|
564
558
|
| Parameter | Type | Description |
|
|
565
|
-
|
|
|
559
|
+
| ------ | ------ | ------ |
|
|
566
560
|
| `fn` | (`error`) => [`Result`](Result.md)\<`T`, `F`\> | A function that takes the `Err` value and returns a `Result`. |
|
|
567
561
|
|
|
568
562
|
#### Returns
|
|
@@ -571,9 +565,9 @@ Calls the provided function with the contained error if `this` is `Err`, otherwi
|
|
|
571
565
|
|
|
572
566
|
The result of `fn` if `this` is `Err`, otherwise `this` as `Ok`.
|
|
573
567
|
|
|
574
|
-
####
|
|
568
|
+
#### Defined in
|
|
575
569
|
|
|
576
|
-
[
|
|
570
|
+
[prelude.ts:540](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L540)
|
|
577
571
|
|
|
578
572
|
***
|
|
579
573
|
|
|
@@ -585,16 +579,16 @@ transpose<T>(this): Option<Result<T, E>>
|
|
|
585
579
|
|
|
586
580
|
Transposes a `Result` of an `Option` into an `Option` of a `Result`.
|
|
587
581
|
|
|
588
|
-
#### Type
|
|
582
|
+
#### Type Parameters
|
|
589
583
|
|
|
590
|
-
| Type
|
|
591
|
-
|
|
|
584
|
+
| Type Parameter | Description |
|
|
585
|
+
| ------ | ------ |
|
|
592
586
|
| `T` | The type of the success value in the `Ok` variant of the `Option`. |
|
|
593
587
|
|
|
594
588
|
#### Parameters
|
|
595
589
|
|
|
596
590
|
| Parameter | Type |
|
|
597
|
-
|
|
|
591
|
+
| ------ | ------ |
|
|
598
592
|
| `this` | [`Result`](Result.md)\<[`Option`](Option.md)\<`T`\>, `E`\> |
|
|
599
593
|
|
|
600
594
|
#### Returns
|
|
@@ -605,9 +599,9 @@ Transposes a `Result` of an `Option` into an `Option` of a `Result`.
|
|
|
605
599
|
`Some` containing `Err` if the result is `Err`,
|
|
606
600
|
`None` if the result is `Ok` containing `None`.
|
|
607
601
|
|
|
608
|
-
####
|
|
602
|
+
#### Defined in
|
|
609
603
|
|
|
610
|
-
[
|
|
604
|
+
[prelude.ts:449](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L449)
|
|
611
605
|
|
|
612
606
|
***
|
|
613
607
|
|
|
@@ -627,9 +621,9 @@ Returns the contained `Ok` value.
|
|
|
627
621
|
|
|
628
622
|
Throws an error if the result is an `Err`.
|
|
629
623
|
|
|
630
|
-
####
|
|
624
|
+
#### Defined in
|
|
631
625
|
|
|
632
|
-
[
|
|
626
|
+
[prelude.ts:389](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L389)
|
|
633
627
|
|
|
634
628
|
***
|
|
635
629
|
|
|
@@ -649,9 +643,9 @@ Returns the contained `Err` value.
|
|
|
649
643
|
|
|
650
644
|
Throws an error if the result is an `Ok`.
|
|
651
645
|
|
|
652
|
-
####
|
|
646
|
+
#### Defined in
|
|
653
647
|
|
|
654
|
-
[
|
|
648
|
+
[prelude.ts:418](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L418)
|
|
655
649
|
|
|
656
650
|
***
|
|
657
651
|
|
|
@@ -666,16 +660,16 @@ Returns the contained `Ok` value or a provided default.
|
|
|
666
660
|
#### Parameters
|
|
667
661
|
|
|
668
662
|
| Parameter | Type | Description |
|
|
669
|
-
|
|
|
663
|
+
| ------ | ------ | ------ |
|
|
670
664
|
| `defaultValue` | `T` | The value to return if the result is an `Err`. |
|
|
671
665
|
|
|
672
666
|
#### Returns
|
|
673
667
|
|
|
674
668
|
`T`
|
|
675
669
|
|
|
676
|
-
####
|
|
670
|
+
#### Defined in
|
|
677
671
|
|
|
678
|
-
[
|
|
672
|
+
[prelude.ts:395](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L395)
|
|
679
673
|
|
|
680
674
|
***
|
|
681
675
|
|
|
@@ -690,13 +684,13 @@ Returns the contained `Ok` value or computes it from a closure if the result is
|
|
|
690
684
|
#### Parameters
|
|
691
685
|
|
|
692
686
|
| Parameter | Type | Description |
|
|
693
|
-
|
|
|
687
|
+
| ------ | ------ | ------ |
|
|
694
688
|
| `fn` | (`error`) => `T` | A function that takes the `Err` value and returns an `Ok` value. |
|
|
695
689
|
|
|
696
690
|
#### Returns
|
|
697
691
|
|
|
698
692
|
`T`
|
|
699
693
|
|
|
700
|
-
####
|
|
694
|
+
#### Defined in
|
|
701
695
|
|
|
702
|
-
[
|
|
696
|
+
[prelude.ts:401](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L401)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
[**happy-rusty**](../
|
|
1
|
+
[**happy-rusty**](../README.md) • **Docs**
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[happy-rusty](../
|
|
5
|
+
[happy-rusty](../README.md) / AsyncIOResult
|
|
6
6
|
|
|
7
|
-
# Type
|
|
7
|
+
# Type Alias: AsyncIOResult\<T\>
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
type AsyncIOResult<T>: Promise<IOResult<T>>;
|
|
@@ -13,12 +13,12 @@ type AsyncIOResult<T>: Promise<IOResult<T>>;
|
|
|
13
13
|
Represents an asynchronous I/O operation that yields a `Result<T, Error>`.
|
|
14
14
|
This is a promise that resolves to `Ok(T)` if the I/O operation was successful, or `Err(Error)` if there was an error.
|
|
15
15
|
|
|
16
|
-
## Type
|
|
16
|
+
## Type Parameters
|
|
17
17
|
|
|
18
|
-
| Type
|
|
19
|
-
|
|
|
18
|
+
| Type Parameter | Description |
|
|
19
|
+
| ------ | ------ |
|
|
20
20
|
| `T` | The type of the value that is produced by a successful I/O operation. |
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Defined in
|
|
23
23
|
|
|
24
|
-
[
|
|
24
|
+
[prelude.ts:607](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L607)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
[**happy-rusty**](../
|
|
1
|
+
[**happy-rusty**](../README.md) • **Docs**
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[happy-rusty](../
|
|
5
|
+
[happy-rusty](../README.md) / AsyncOption
|
|
6
6
|
|
|
7
|
-
# Type
|
|
7
|
+
# Type Alias: AsyncOption\<T\>
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
type AsyncOption<T>: Promise<Option<T>>;
|
|
@@ -13,12 +13,12 @@ type AsyncOption<T>: Promise<Option<T>>;
|
|
|
13
13
|
Represents an asynchronous operation that yields an `Option<T>`.
|
|
14
14
|
This is a promise that resolves to either `Some(T)` if the value is present, or `None` if the value is absent.
|
|
15
15
|
|
|
16
|
-
## Type
|
|
16
|
+
## Type Parameters
|
|
17
17
|
|
|
18
|
-
| Type
|
|
19
|
-
|
|
|
18
|
+
| Type Parameter | Description |
|
|
19
|
+
| ------ | ------ |
|
|
20
20
|
| `T` | The type of the value that may be contained within the `Option`. |
|
|
21
21
|
|
|
22
|
-
##
|
|
22
|
+
## Defined in
|
|
23
23
|
|
|
24
|
-
[
|
|
24
|
+
[prelude.ts:582](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L582)
|