happy-rusty 1.1.0 → 1.1.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/README.cn.md +1 -1
- package/README.md +1 -1
- package/dist/main.cjs +12 -0
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +12 -0
- package/dist/main.mjs.map +1 -1
- package/dist/types.d.ts +19 -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 +161 -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 +35 -2
package/docs/interfaces/None.md
CHANGED
|
@@ -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) / None
|
|
6
6
|
|
|
7
7
|
# Interface: None
|
|
8
8
|
|
|
@@ -15,9 +15,9 @@ The type parameter is set to `never` because `None` does not hold a value.
|
|
|
15
15
|
|
|
16
16
|
## Properties
|
|
17
17
|
|
|
18
|
-
| Property | Modifier | Type | Description | Overrides |
|
|
19
|
-
|
|
|
20
|
-
| `[optionKindSymbol]` | `readonly` | `"None"` | When using `None` alone, the following overrides can make type inference more accurate. |
|
|
18
|
+
| Property | Modifier | Type | Description | Overrides | Defined in |
|
|
19
|
+
| ------ | ------ | ------ | ------ | ------ | ------ |
|
|
20
|
+
| `[optionKindSymbol]` | `readonly` | `"None"` | When using `None` alone, the following overrides can make type inference more accurate. | `Option.[optionKindSymbol]` | [prelude.ts:291](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L291) |
|
|
21
21
|
|
|
22
22
|
## Methods
|
|
23
23
|
|
|
@@ -30,16 +30,16 @@ and<U>(other): None
|
|
|
30
30
|
Returns `None` if the Option is `None`, otherwise returns `other`.
|
|
31
31
|
This is sometimes called "and then" because it is similar to a logical AND operation.
|
|
32
32
|
|
|
33
|
-
#### Type
|
|
33
|
+
#### Type Parameters
|
|
34
34
|
|
|
35
|
-
| Type
|
|
36
|
-
|
|
|
35
|
+
| Type Parameter | Description |
|
|
36
|
+
| ------ | ------ |
|
|
37
37
|
| `U` | The type of the value in the other `Option`. |
|
|
38
38
|
|
|
39
39
|
#### Parameters
|
|
40
40
|
|
|
41
41
|
| Parameter | Type | Description |
|
|
42
|
-
|
|
|
42
|
+
| ------ | ------ | ------ |
|
|
43
43
|
| `other` | [`Option`](Option.md)\<`U`\> | The `Option` to return if `this` is `Some`. |
|
|
44
44
|
|
|
45
45
|
#### Returns
|
|
@@ -52,9 +52,9 @@ This is sometimes called "and then" because it is similar to a logical AND opera
|
|
|
52
52
|
|
|
53
53
|
[`Option`](Option.md).[`and`](Option.md#and)
|
|
54
54
|
|
|
55
|
-
####
|
|
55
|
+
#### Defined in
|
|
56
56
|
|
|
57
|
-
[
|
|
57
|
+
[prelude.ts:306](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L306)
|
|
58
58
|
|
|
59
59
|
***
|
|
60
60
|
|
|
@@ -67,16 +67,16 @@ andThen<U>(fn): None
|
|
|
67
67
|
Returns `None` if the Option is `None`, otherwise calls `fn` with the wrapped value and returns the result.
|
|
68
68
|
This function can be used for control flow based on `Option` values.
|
|
69
69
|
|
|
70
|
-
#### Type
|
|
70
|
+
#### Type Parameters
|
|
71
71
|
|
|
72
|
-
| Type
|
|
73
|
-
|
|
|
72
|
+
| Type Parameter | Description |
|
|
73
|
+
| ------ | ------ |
|
|
74
74
|
| `U` | The type of the value returned by the function. |
|
|
75
75
|
|
|
76
76
|
#### Parameters
|
|
77
77
|
|
|
78
78
|
| Parameter | Type | Description |
|
|
79
|
-
|
|
|
79
|
+
| ------ | ------ | ------ |
|
|
80
80
|
| `fn` | (`value`) => [`Option`](Option.md)\<`U`\> | A function that takes the contained value and returns an `Option`. |
|
|
81
81
|
|
|
82
82
|
#### Returns
|
|
@@ -89,9 +89,9 @@ The result of `fn` if `this` is `Some`, otherwise `None`.
|
|
|
89
89
|
|
|
90
90
|
[`Option`](Option.md).[`andThen`](Option.md#andthen)
|
|
91
91
|
|
|
92
|
-
####
|
|
92
|
+
#### Defined in
|
|
93
93
|
|
|
94
|
-
[
|
|
94
|
+
[prelude.ts:307](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L307)
|
|
95
95
|
|
|
96
96
|
***
|
|
97
97
|
|
|
@@ -104,16 +104,16 @@ eq<T>(other): boolean
|
|
|
104
104
|
Tests whether `this` and `other` are both `Some` containing equal values, or both are `None`.
|
|
105
105
|
This method can be used for comparing `Option` instances in a value-sensitive manner.
|
|
106
106
|
|
|
107
|
-
#### Type
|
|
107
|
+
#### Type Parameters
|
|
108
108
|
|
|
109
|
-
| Type
|
|
110
|
-
|
|
|
109
|
+
| Type Parameter |
|
|
110
|
+
| ------ |
|
|
111
111
|
| `T` |
|
|
112
112
|
|
|
113
113
|
#### Parameters
|
|
114
114
|
|
|
115
115
|
| Parameter | Type | Description |
|
|
116
|
-
|
|
|
116
|
+
| ------ | ------ | ------ |
|
|
117
117
|
| `other` | [`Option`](Option.md)\<`T`\> | The other `Option` to compare with. |
|
|
118
118
|
|
|
119
119
|
#### Returns
|
|
@@ -126,9 +126,9 @@ This method can be used for comparing `Option` instances in a value-sensitive ma
|
|
|
126
126
|
|
|
127
127
|
[`Option`](Option.md).[`eq`](Option.md#eq)
|
|
128
128
|
|
|
129
|
-
####
|
|
129
|
+
#### Defined in
|
|
130
130
|
|
|
131
|
-
[
|
|
131
|
+
[prelude.ts:312](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L312)
|
|
132
132
|
|
|
133
133
|
***
|
|
134
134
|
|
|
@@ -143,24 +143,24 @@ Returns the contained `Some` value, with a provided error message if the value i
|
|
|
143
143
|
#### Parameters
|
|
144
144
|
|
|
145
145
|
| Parameter | Type | Description |
|
|
146
|
-
|
|
|
146
|
+
| ------ | ------ | ------ |
|
|
147
147
|
| `msg` | `string` | The error message to provide if the value is a `None`. |
|
|
148
148
|
|
|
149
149
|
#### Returns
|
|
150
150
|
|
|
151
151
|
`never`
|
|
152
152
|
|
|
153
|
-
#### Inherited from
|
|
154
|
-
|
|
155
|
-
[`Option`](Option.md).[`expect`](Option.md#expect)
|
|
156
|
-
|
|
157
153
|
#### Throws
|
|
158
154
|
|
|
159
155
|
Throws an error with the provided message if the Option is a `None`.
|
|
160
156
|
|
|
161
|
-
####
|
|
157
|
+
#### Inherited from
|
|
158
|
+
|
|
159
|
+
[`Option`](Option.md).[`expect`](Option.md#expect)
|
|
160
|
+
|
|
161
|
+
#### Defined in
|
|
162
162
|
|
|
163
|
-
[
|
|
163
|
+
[prelude.ts:80](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L80)
|
|
164
164
|
|
|
165
165
|
***
|
|
166
166
|
|
|
@@ -177,7 +177,7 @@ Returns `None` if the Option is `None`, otherwise calls predicate with the wrapp
|
|
|
177
177
|
#### Parameters
|
|
178
178
|
|
|
179
179
|
| Parameter | Type | Description |
|
|
180
|
-
|
|
|
180
|
+
| ------ | ------ | ------ |
|
|
181
181
|
| `predicate` | (`value`) => `boolean` | A function that takes the contained value and returns a boolean. |
|
|
182
182
|
|
|
183
183
|
#### Returns
|
|
@@ -188,9 +188,9 @@ Returns `None` if the Option is `None`, otherwise calls predicate with the wrapp
|
|
|
188
188
|
|
|
189
189
|
[`Option`](Option.md).[`filter`](Option.md#filter)
|
|
190
190
|
|
|
191
|
-
####
|
|
191
|
+
#### Defined in
|
|
192
192
|
|
|
193
|
-
[
|
|
193
|
+
[prelude.ts:298](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L298)
|
|
194
194
|
|
|
195
195
|
***
|
|
196
196
|
|
|
@@ -212,9 +212,9 @@ Converts from `Option<Option<T>>` to `Option<T>`.
|
|
|
212
212
|
|
|
213
213
|
[`Option`](Option.md).[`flatten`](Option.md#flatten)
|
|
214
214
|
|
|
215
|
-
####
|
|
215
|
+
#### Defined in
|
|
216
216
|
|
|
217
|
-
[
|
|
217
|
+
[prelude.ts:299](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L299)
|
|
218
218
|
|
|
219
219
|
***
|
|
220
220
|
|
|
@@ -230,7 +230,7 @@ This is primarily for side effects and does not transform the `Option`.
|
|
|
230
230
|
#### Parameters
|
|
231
231
|
|
|
232
232
|
| Parameter | Type | Description |
|
|
233
|
-
|
|
|
233
|
+
| ------ | ------ | ------ |
|
|
234
234
|
| `fn` | (`value`) => `void` | A function to call with the contained value. |
|
|
235
235
|
|
|
236
236
|
#### Returns
|
|
@@ -243,9 +243,9 @@ This is primarily for side effects and does not transform the `Option`.
|
|
|
243
243
|
|
|
244
244
|
[`Option`](Option.md).[`inspect`](Option.md#inspect)
|
|
245
245
|
|
|
246
|
-
####
|
|
246
|
+
#### Defined in
|
|
247
247
|
|
|
248
|
-
[
|
|
248
|
+
[prelude.ts:267](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L267)
|
|
249
249
|
|
|
250
250
|
***
|
|
251
251
|
|
|
@@ -265,9 +265,9 @@ Returns `true` if the Option is a `None` value.
|
|
|
265
265
|
|
|
266
266
|
[`Option`](Option.md).[`isNone`](Option.md#isnone)
|
|
267
267
|
|
|
268
|
-
####
|
|
268
|
+
#### Defined in
|
|
269
269
|
|
|
270
|
-
[
|
|
270
|
+
[prelude.ts:59](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L59)
|
|
271
271
|
|
|
272
272
|
***
|
|
273
273
|
|
|
@@ -287,9 +287,9 @@ Returns `true` if the Option is a `Some` value.
|
|
|
287
287
|
|
|
288
288
|
[`Option`](Option.md).[`isSome`](Option.md#issome)
|
|
289
289
|
|
|
290
|
-
####
|
|
290
|
+
#### Defined in
|
|
291
291
|
|
|
292
|
-
[
|
|
292
|
+
[prelude.ts:54](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L54)
|
|
293
293
|
|
|
294
294
|
***
|
|
295
295
|
|
|
@@ -304,7 +304,7 @@ Returns `true` if the Option is a `Some` value and the predicate returns `true`
|
|
|
304
304
|
#### Parameters
|
|
305
305
|
|
|
306
306
|
| Parameter | Type | Description |
|
|
307
|
-
|
|
|
307
|
+
| ------ | ------ | ------ |
|
|
308
308
|
| `predicate` | (`value`) => `boolean` | A function that takes the contained value and returns a boolean. |
|
|
309
309
|
|
|
310
310
|
#### Returns
|
|
@@ -315,9 +315,9 @@ Returns `true` if the Option is a `Some` value and the predicate returns `true`
|
|
|
315
315
|
|
|
316
316
|
[`Option`](Option.md).[`isSomeAnd`](Option.md#issomeand)
|
|
317
317
|
|
|
318
|
-
####
|
|
318
|
+
#### Defined in
|
|
319
319
|
|
|
320
|
-
[
|
|
320
|
+
[prelude.ts:65](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L65)
|
|
321
321
|
|
|
322
322
|
***
|
|
323
323
|
|
|
@@ -329,16 +329,16 @@ map<U>(fn): None
|
|
|
329
329
|
|
|
330
330
|
Maps an `Option<T>` to `Option<U>` by applying a function to a contained value.
|
|
331
331
|
|
|
332
|
-
#### Type
|
|
332
|
+
#### Type Parameters
|
|
333
333
|
|
|
334
|
-
| Type
|
|
335
|
-
|
|
|
334
|
+
| Type Parameter | Description |
|
|
335
|
+
| ------ | ------ |
|
|
336
336
|
| `U` | The type of the value returned by the map function. |
|
|
337
337
|
|
|
338
338
|
#### Parameters
|
|
339
339
|
|
|
340
340
|
| Parameter | Type | Description |
|
|
341
|
-
|
|
|
341
|
+
| ------ | ------ | ------ |
|
|
342
342
|
| `fn` | (`value`) => `U` | A function that takes the contained value and returns a new value. |
|
|
343
343
|
|
|
344
344
|
#### Returns
|
|
@@ -349,9 +349,9 @@ Maps an `Option<T>` to `Option<U>` by applying a function to a contained value.
|
|
|
349
349
|
|
|
350
350
|
[`Option`](Option.md).[`map`](Option.md#map)
|
|
351
351
|
|
|
352
|
-
####
|
|
352
|
+
#### Defined in
|
|
353
353
|
|
|
354
|
-
[
|
|
354
|
+
[prelude.ts:300](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L300)
|
|
355
355
|
|
|
356
356
|
***
|
|
357
357
|
|
|
@@ -363,16 +363,16 @@ mapOr<U>(defaultValue, fn): U
|
|
|
363
363
|
|
|
364
364
|
Maps an `Option<T>` to `U` by applying a function to the contained value (if any), or returns the provided default (if not).
|
|
365
365
|
|
|
366
|
-
#### Type
|
|
366
|
+
#### Type Parameters
|
|
367
367
|
|
|
368
|
-
| Type
|
|
369
|
-
|
|
|
368
|
+
| Type Parameter | Description |
|
|
369
|
+
| ------ | ------ |
|
|
370
370
|
| `U` | The type of the value returned by the map function or the default value. |
|
|
371
371
|
|
|
372
372
|
#### Parameters
|
|
373
373
|
|
|
374
374
|
| Parameter | Type | Description |
|
|
375
|
-
|
|
|
375
|
+
| ------ | ------ | ------ |
|
|
376
376
|
| `defaultValue` | `U` | The value to return if the Option is `None`. |
|
|
377
377
|
| `fn` | (`value`) => `U` | A function that takes the contained value and returns a new value. |
|
|
378
378
|
|
|
@@ -384,9 +384,9 @@ Maps an `Option<T>` to `U` by applying a function to the contained value (if any
|
|
|
384
384
|
|
|
385
385
|
[`Option`](Option.md).[`mapOr`](Option.md#mapor)
|
|
386
386
|
|
|
387
|
-
####
|
|
387
|
+
#### Defined in
|
|
388
388
|
|
|
389
|
-
[
|
|
389
|
+
[prelude.ts:163](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L163)
|
|
390
390
|
|
|
391
391
|
***
|
|
392
392
|
|
|
@@ -398,16 +398,16 @@ mapOrElse<U>(defaultFn, fn): U
|
|
|
398
398
|
|
|
399
399
|
Maps an `Option<T>` to `U` by applying a function to a contained value (if any), or computes a default (if not).
|
|
400
400
|
|
|
401
|
-
#### Type
|
|
401
|
+
#### Type Parameters
|
|
402
402
|
|
|
403
|
-
| Type
|
|
404
|
-
|
|
|
403
|
+
| Type Parameter | Description |
|
|
404
|
+
| ------ | ------ |
|
|
405
405
|
| `U` | The type of the value returned by the map function or the default function. |
|
|
406
406
|
|
|
407
407
|
#### Parameters
|
|
408
408
|
|
|
409
409
|
| Parameter | Type | Description |
|
|
410
|
-
|
|
|
410
|
+
| ------ | ------ | ------ |
|
|
411
411
|
| `defaultFn` | () => `U` | A function that returns the default value. |
|
|
412
412
|
| `fn` | (`value`) => `U` | A function that takes the contained value and returns a new value. |
|
|
413
413
|
|
|
@@ -419,9 +419,9 @@ Maps an `Option<T>` to `U` by applying a function to a contained value (if any),
|
|
|
419
419
|
|
|
420
420
|
[`Option`](Option.md).[`mapOrElse`](Option.md#maporelse)
|
|
421
421
|
|
|
422
|
-
####
|
|
422
|
+
#### Defined in
|
|
423
423
|
|
|
424
|
-
[
|
|
424
|
+
[prelude.ts:171](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L171)
|
|
425
425
|
|
|
426
426
|
***
|
|
427
427
|
|
|
@@ -433,16 +433,16 @@ okOr<E>(error): Result<never, E>
|
|
|
433
433
|
|
|
434
434
|
Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to `Ok(v)` and `None` to `Err(err)`.
|
|
435
435
|
|
|
436
|
-
#### Type
|
|
436
|
+
#### Type Parameters
|
|
437
437
|
|
|
438
|
-
| Type
|
|
439
|
-
|
|
|
438
|
+
| Type Parameter | Description |
|
|
439
|
+
| ------ | ------ |
|
|
440
440
|
| `E` | The type of the error value in the `Err` variant of the resulting `Result`. |
|
|
441
441
|
|
|
442
442
|
#### Parameters
|
|
443
443
|
|
|
444
444
|
| Parameter | Type | Description |
|
|
445
|
-
|
|
|
445
|
+
| ------ | ------ | ------ |
|
|
446
446
|
| `error` | `E` | The error value to use if the Option is a `None`. |
|
|
447
447
|
|
|
448
448
|
#### Returns
|
|
@@ -453,9 +453,9 @@ Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to `Ok(v)` a
|
|
|
453
453
|
|
|
454
454
|
[`Option`](Option.md).[`okOr`](Option.md#okor)
|
|
455
455
|
|
|
456
|
-
####
|
|
456
|
+
#### Defined in
|
|
457
457
|
|
|
458
|
-
[
|
|
458
|
+
[prelude.ts:113](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L113)
|
|
459
459
|
|
|
460
460
|
***
|
|
461
461
|
|
|
@@ -467,16 +467,16 @@ okOrElse<E>(err): Result<never, E>
|
|
|
467
467
|
|
|
468
468
|
Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to `Ok(v)` and `None` to `Err(err())`.
|
|
469
469
|
|
|
470
|
-
#### Type
|
|
470
|
+
#### Type Parameters
|
|
471
471
|
|
|
472
|
-
| Type
|
|
473
|
-
|
|
|
472
|
+
| Type Parameter | Description |
|
|
473
|
+
| ------ | ------ |
|
|
474
474
|
| `E` | The type of the error value in the `Err` variant of the resulting `Result`. |
|
|
475
475
|
|
|
476
476
|
#### Parameters
|
|
477
477
|
|
|
478
478
|
| Parameter | Type | Description |
|
|
479
|
-
|
|
|
479
|
+
| ------ | ------ | ------ |
|
|
480
480
|
| `err` | () => `E` | A function that returns the error value. |
|
|
481
481
|
|
|
482
482
|
#### Returns
|
|
@@ -487,9 +487,9 @@ Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to `Ok(v)` a
|
|
|
487
487
|
|
|
488
488
|
[`Option`](Option.md).[`okOrElse`](Option.md#okorelse)
|
|
489
489
|
|
|
490
|
-
####
|
|
490
|
+
#### Defined in
|
|
491
491
|
|
|
492
|
-
[
|
|
492
|
+
[prelude.ts:120](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L120)
|
|
493
493
|
|
|
494
494
|
***
|
|
495
495
|
|
|
@@ -502,16 +502,16 @@ or<T>(other): Option<T>
|
|
|
502
502
|
Returns the Option if it contains a value, otherwise returns `other`.
|
|
503
503
|
This can be used for providing a fallback `Option`.
|
|
504
504
|
|
|
505
|
-
#### Type
|
|
505
|
+
#### Type Parameters
|
|
506
506
|
|
|
507
|
-
| Type
|
|
508
|
-
|
|
|
507
|
+
| Type Parameter |
|
|
508
|
+
| ------ |
|
|
509
509
|
| `T` |
|
|
510
510
|
|
|
511
511
|
#### Parameters
|
|
512
512
|
|
|
513
513
|
| Parameter | Type | Description |
|
|
514
|
-
|
|
|
514
|
+
| ------ | ------ | ------ |
|
|
515
515
|
| `other` | [`Option`](Option.md)\<`T`\> | The fallback `Option` to use if `this` is `None`. |
|
|
516
516
|
|
|
517
517
|
#### Returns
|
|
@@ -524,9 +524,9 @@ This can be used for providing a fallback `Option`.
|
|
|
524
524
|
|
|
525
525
|
[`Option`](Option.md).[`or`](Option.md#or)
|
|
526
526
|
|
|
527
|
-
####
|
|
527
|
+
#### Defined in
|
|
528
528
|
|
|
529
|
-
[
|
|
529
|
+
[prelude.ts:308](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L308)
|
|
530
530
|
|
|
531
531
|
***
|
|
532
532
|
|
|
@@ -539,16 +539,16 @@ orElse<T>(fn): Option<T>
|
|
|
539
539
|
Returns the Option if it contains a value, otherwise calls `fn` and returns the result.
|
|
540
540
|
This method can be used for lazy fallbacks, as `fn` is only evaluated if `this` is `None`.
|
|
541
541
|
|
|
542
|
-
#### Type
|
|
542
|
+
#### Type Parameters
|
|
543
543
|
|
|
544
|
-
| Type
|
|
545
|
-
|
|
|
544
|
+
| Type Parameter |
|
|
545
|
+
| ------ |
|
|
546
546
|
| `T` |
|
|
547
547
|
|
|
548
548
|
#### Parameters
|
|
549
549
|
|
|
550
550
|
| Parameter | Type | Description |
|
|
551
|
-
|
|
|
551
|
+
| ------ | ------ | ------ |
|
|
552
552
|
| `fn` | () => [`Option`](Option.md)\<`T`\> | A function that produces an `Option`. |
|
|
553
553
|
|
|
554
554
|
#### Returns
|
|
@@ -561,9 +561,9 @@ This method can be used for lazy fallbacks, as `fn` is only evaluated if `this`
|
|
|
561
561
|
|
|
562
562
|
[`Option`](Option.md).[`orElse`](Option.md#orelse)
|
|
563
563
|
|
|
564
|
-
####
|
|
564
|
+
#### Defined in
|
|
565
565
|
|
|
566
|
-
[
|
|
566
|
+
[prelude.ts:309](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L309)
|
|
567
567
|
|
|
568
568
|
***
|
|
569
569
|
|
|
@@ -587,9 +587,9 @@ Transposes an `Option` of a `Result` into a `Result` of an `Option`.
|
|
|
587
587
|
|
|
588
588
|
[`Option`](Option.md).[`transpose`](Option.md#transpose)
|
|
589
589
|
|
|
590
|
-
####
|
|
590
|
+
#### Defined in
|
|
591
591
|
|
|
592
|
-
[
|
|
592
|
+
[prelude.ts:296](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L296)
|
|
593
593
|
|
|
594
594
|
***
|
|
595
595
|
|
|
@@ -605,17 +605,17 @@ Returns the contained `Some` value.
|
|
|
605
605
|
|
|
606
606
|
`never`
|
|
607
607
|
|
|
608
|
-
#### Inherited from
|
|
609
|
-
|
|
610
|
-
[`Option`](Option.md).[`unwrap`](Option.md#unwrap)
|
|
611
|
-
|
|
612
608
|
#### Throws
|
|
613
609
|
|
|
614
610
|
Throws an error if the value is a `None`.
|
|
615
611
|
|
|
616
|
-
####
|
|
612
|
+
#### Inherited from
|
|
613
|
+
|
|
614
|
+
[`Option`](Option.md).[`unwrap`](Option.md#unwrap)
|
|
615
|
+
|
|
616
|
+
#### Defined in
|
|
617
617
|
|
|
618
|
-
[
|
|
618
|
+
[prelude.ts:86](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L86)
|
|
619
619
|
|
|
620
620
|
***
|
|
621
621
|
|
|
@@ -627,16 +627,16 @@ unwrapOr<T>(defaultValue): T
|
|
|
627
627
|
|
|
628
628
|
Returns the contained `Some` value or a provided default.
|
|
629
629
|
|
|
630
|
-
#### Type
|
|
630
|
+
#### Type Parameters
|
|
631
631
|
|
|
632
|
-
| Type
|
|
633
|
-
|
|
|
632
|
+
| Type Parameter |
|
|
633
|
+
| ------ |
|
|
634
634
|
| `T` |
|
|
635
635
|
|
|
636
636
|
#### Parameters
|
|
637
637
|
|
|
638
638
|
| Parameter | Type | Description |
|
|
639
|
-
|
|
|
639
|
+
| ------ | ------ | ------ |
|
|
640
640
|
| `defaultValue` | `T` | The value to return if the Option is a `None`. |
|
|
641
641
|
|
|
642
642
|
#### Returns
|
|
@@ -647,9 +647,9 @@ Returns the contained `Some` value or a provided default.
|
|
|
647
647
|
|
|
648
648
|
[`Option`](Option.md).[`unwrapOr`](Option.md#unwrapor)
|
|
649
649
|
|
|
650
|
-
####
|
|
650
|
+
#### Defined in
|
|
651
651
|
|
|
652
|
-
[
|
|
652
|
+
[prelude.ts:293](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L293)
|
|
653
653
|
|
|
654
654
|
***
|
|
655
655
|
|
|
@@ -661,16 +661,16 @@ unwrapOrElse<T>(fn): T
|
|
|
661
661
|
|
|
662
662
|
Returns the contained `Some` value or computes it from a closure.
|
|
663
663
|
|
|
664
|
-
#### Type
|
|
664
|
+
#### Type Parameters
|
|
665
665
|
|
|
666
|
-
| Type
|
|
667
|
-
|
|
|
666
|
+
| Type Parameter |
|
|
667
|
+
| ------ |
|
|
668
668
|
| `T` |
|
|
669
669
|
|
|
670
670
|
#### Parameters
|
|
671
671
|
|
|
672
672
|
| Parameter | Type | Description |
|
|
673
|
-
|
|
|
673
|
+
| ------ | ------ | ------ |
|
|
674
674
|
| `fn` | () => `T` | A function that returns the default value. |
|
|
675
675
|
|
|
676
676
|
#### Returns
|
|
@@ -681,9 +681,9 @@ Returns the contained `Some` value or computes it from a closure.
|
|
|
681
681
|
|
|
682
682
|
[`Option`](Option.md).[`unwrapOrElse`](Option.md#unwraporelse)
|
|
683
683
|
|
|
684
|
-
####
|
|
684
|
+
#### Defined in
|
|
685
685
|
|
|
686
|
-
[
|
|
686
|
+
[prelude.ts:294](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L294)
|
|
687
687
|
|
|
688
688
|
***
|
|
689
689
|
|
|
@@ -707,9 +707,9 @@ A tuple of `Options`, one for each element in the original `Option` of a tuple.
|
|
|
707
707
|
|
|
708
708
|
[`Option`](Option.md).[`unzip`](Option.md#unzip)
|
|
709
709
|
|
|
710
|
-
####
|
|
710
|
+
#### Defined in
|
|
711
711
|
|
|
712
|
-
[
|
|
712
|
+
[prelude.ts:304](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L304)
|
|
713
713
|
|
|
714
714
|
***
|
|
715
715
|
|
|
@@ -722,16 +722,16 @@ xor<T>(other): Option<T>
|
|
|
722
722
|
Returns `Some` if exactly one of `this`, `other` is `Some`, otherwise returns `None`.
|
|
723
723
|
This can be thought of as an exclusive or operation on `Option` values.
|
|
724
724
|
|
|
725
|
-
#### Type
|
|
725
|
+
#### Type Parameters
|
|
726
726
|
|
|
727
|
-
| Type
|
|
728
|
-
|
|
|
727
|
+
| Type Parameter |
|
|
728
|
+
| ------ |
|
|
729
729
|
| `T` |
|
|
730
730
|
|
|
731
731
|
#### Parameters
|
|
732
732
|
|
|
733
733
|
| Parameter | Type | Description |
|
|
734
|
-
|
|
|
734
|
+
| ------ | ------ | ------ |
|
|
735
735
|
| `other` | [`Option`](Option.md)\<`T`\> | The other `Option` to compare with. |
|
|
736
736
|
|
|
737
737
|
#### Returns
|
|
@@ -744,9 +744,9 @@ This can be thought of as an exclusive or operation on `Option` values.
|
|
|
744
744
|
|
|
745
745
|
[`Option`](Option.md).[`xor`](Option.md#xor)
|
|
746
746
|
|
|
747
|
-
####
|
|
747
|
+
#### Defined in
|
|
748
748
|
|
|
749
|
-
[
|
|
749
|
+
[prelude.ts:310](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L310)
|
|
750
750
|
|
|
751
751
|
***
|
|
752
752
|
|
|
@@ -760,16 +760,16 @@ Combines `this` with another `Option` by zipping their contained values.
|
|
|
760
760
|
If `this` is `Some(s)` and `other` is `Some(o)`, returns `Some([s, o])`.
|
|
761
761
|
If either `this` or `other` is `None`, returns `None`.
|
|
762
762
|
|
|
763
|
-
#### Type
|
|
763
|
+
#### Type Parameters
|
|
764
764
|
|
|
765
|
-
| Type
|
|
766
|
-
|
|
|
765
|
+
| Type Parameter | Description |
|
|
766
|
+
| ------ | ------ |
|
|
767
767
|
| `U` | The type of the value in the other `Option`. |
|
|
768
768
|
|
|
769
769
|
#### Parameters
|
|
770
770
|
|
|
771
771
|
| Parameter | Type | Description |
|
|
772
|
-
|
|
|
772
|
+
| ------ | ------ | ------ |
|
|
773
773
|
| `other` | [`Option`](Option.md)\<`U`\> | The other `Option` to zip with. |
|
|
774
774
|
|
|
775
775
|
#### Returns
|
|
@@ -782,9 +782,9 @@ An `Option` containing a tuple of the values if both are `Some`, otherwise `None
|
|
|
782
782
|
|
|
783
783
|
[`Option`](Option.md).[`zip`](Option.md#zip)
|
|
784
784
|
|
|
785
|
-
####
|
|
785
|
+
#### Defined in
|
|
786
786
|
|
|
787
|
-
[
|
|
787
|
+
[prelude.ts:302](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L302)
|
|
788
788
|
|
|
789
789
|
***
|
|
790
790
|
|
|
@@ -798,17 +798,17 @@ Zips `this` with another `Option` using a provided function to combine their con
|
|
|
798
798
|
If `this` is `Some(s)` and `other` is `Some(o)`, returns `Some(fn(s, o))`.
|
|
799
799
|
If either `this` or `other` is `None`, returns `None`.
|
|
800
800
|
|
|
801
|
-
#### Type
|
|
801
|
+
#### Type Parameters
|
|
802
802
|
|
|
803
|
-
| Type
|
|
804
|
-
|
|
|
803
|
+
| Type Parameter | Description |
|
|
804
|
+
| ------ | ------ |
|
|
805
805
|
| `U` | The type of the value in the other `Option`. |
|
|
806
806
|
| `R` | The return type of the combining function. |
|
|
807
807
|
|
|
808
808
|
#### Parameters
|
|
809
809
|
|
|
810
810
|
| Parameter | Type | Description |
|
|
811
|
-
|
|
|
811
|
+
| ------ | ------ | ------ |
|
|
812
812
|
| `other` | [`Option`](Option.md)\<`U`\> | The other `Option` to zip with. |
|
|
813
813
|
| `fn` | (`value`, `otherValue`) => `R` | The function to combine the values from both `Options`. |
|
|
814
814
|
|
|
@@ -822,6 +822,6 @@ An `Option` containing the result of `fn` if both `Options` are `Some`, otherwis
|
|
|
822
822
|
|
|
823
823
|
[`Option`](Option.md).[`zipWith`](Option.md#zipwith)
|
|
824
824
|
|
|
825
|
-
####
|
|
825
|
+
#### Defined in
|
|
826
826
|
|
|
827
|
-
[
|
|
827
|
+
[prelude.ts:303](https://github.com/JiangJie/happy-rusty/blob/7218a182717eb5dbba4bfaf783977bc5e378815a/src/enum/prelude.ts#L303)
|