happy-rusty 1.0.9 → 1.1.0

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.
@@ -0,0 +1,743 @@
1
+ [**happy-rusty**](../index.md) • **Docs**
2
+
3
+ ***
4
+
5
+ [happy-rusty](../index.md) / Option
6
+
7
+ # Interface: Option\<T\>
8
+
9
+ Type `Option` represents an optional value: every `Option` is either `Some` and contains a value, or `None`, and does not.
10
+ This interface includes methods that act on the `Option` type, similar to Rust's `Option` enum.
11
+
12
+ As Rust Code:
13
+ ```rust
14
+ pub enum Option<T> {
15
+ None,
16
+ Some(T),
17
+ }
18
+ ```
19
+
20
+ ## Extended by
21
+
22
+ - [`None`](None.md)
23
+
24
+ ## Type parameters
25
+
26
+ | Type parameter | Description |
27
+ | :------ | :------ |
28
+ | `T` | The type of the value contained in the `Some` variant. |
29
+
30
+ ## Properties
31
+
32
+ | Property | Modifier | Type | Description |
33
+ | :------ | :------ | :------ | :------ |
34
+ | `[optionKindSymbol]` | `private` | `"Some"` \| `"None"` | Identify `Some` or `None`. |
35
+
36
+ ## Methods
37
+
38
+ ### and()
39
+
40
+ ```ts
41
+ and<U>(other): Option<U>
42
+ ```
43
+
44
+ Returns `None` if the Option is `None`, otherwise returns `other`.
45
+ This is sometimes called "and then" because it is similar to a logical AND operation.
46
+
47
+ #### Type parameters
48
+
49
+ | Type parameter | Description |
50
+ | :------ | :------ |
51
+ | `U` | The type of the value in the other `Option`. |
52
+
53
+ #### Parameters
54
+
55
+ | Parameter | Type | Description |
56
+ | :------ | :------ | :------ |
57
+ | `other` | [`Option`](Option.md)\<`U`\> | The `Option` to return if `this` is `Some`. |
58
+
59
+ #### Returns
60
+
61
+ [`Option`](Option.md)\<`U`\>
62
+
63
+ `None` if `this` is `None`, otherwise returns `other`.
64
+
65
+ #### Source
66
+
67
+ [enum/prelude.ts:224](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L224)
68
+
69
+ ***
70
+
71
+ ### andThen()
72
+
73
+ ```ts
74
+ andThen<U>(fn): Option<U>
75
+ ```
76
+
77
+ Returns `None` if the Option is `None`, otherwise calls `fn` with the wrapped value and returns the result.
78
+ This function can be used for control flow based on `Option` values.
79
+
80
+ #### Type parameters
81
+
82
+ | Type parameter | Description |
83
+ | :------ | :------ |
84
+ | `U` | The type of the value returned by the function. |
85
+
86
+ #### Parameters
87
+
88
+ | Parameter | Type | Description |
89
+ | :------ | :------ | :------ |
90
+ | `fn` | (`value`) => [`Option`](Option.md)\<`U`\> | A function that takes the contained value and returns an `Option`. |
91
+
92
+ #### Returns
93
+
94
+ [`Option`](Option.md)\<`U`\>
95
+
96
+ The result of `fn` if `this` is `Some`, otherwise `None`.
97
+
98
+ #### Source
99
+
100
+ [enum/prelude.ts:233](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L233)
101
+
102
+ ***
103
+
104
+ ### eq()
105
+
106
+ ```ts
107
+ eq(other): boolean
108
+ ```
109
+
110
+ Tests whether `this` and `other` are both `Some` containing equal values, or both are `None`.
111
+ This method can be used for comparing `Option` instances in a value-sensitive manner.
112
+
113
+ #### Parameters
114
+
115
+ | Parameter | Type | Description |
116
+ | :------ | :------ | :------ |
117
+ | `other` | [`Option`](Option.md)\<`T`\> | The other `Option` to compare with. |
118
+
119
+ #### Returns
120
+
121
+ `boolean`
122
+
123
+ `true` if `this` and `other` are both `Some` with equal values, or both are `None`, otherwise `false`.
124
+
125
+ #### Source
126
+
127
+ [enum/prelude.ts:277](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L277)
128
+
129
+ ***
130
+
131
+ ### expect()
132
+
133
+ ```ts
134
+ expect(msg): T
135
+ ```
136
+
137
+ Returns the contained `Some` value, with a provided error message if the value is a `None`.
138
+
139
+ #### Parameters
140
+
141
+ | Parameter | Type | Description |
142
+ | :------ | :------ | :------ |
143
+ | `msg` | `string` | The error message to provide if the value is a `None`. |
144
+
145
+ #### Returns
146
+
147
+ `T`
148
+
149
+ #### Throws
150
+
151
+ Throws an error with the provided message if the Option is a `None`.
152
+
153
+ #### Source
154
+
155
+ [enum/prelude.ts:80](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L80)
156
+
157
+ ***
158
+
159
+ ### filter()
160
+
161
+ ```ts
162
+ filter(predicate): Option<T>
163
+ ```
164
+
165
+ Returns `None` if the Option is `None`, otherwise calls predicate with the wrapped value and returns:
166
+ - `Some(t)` if predicate returns `true` (where `t` is the wrapped value), and
167
+ - `None` if predicate returns `false`.
168
+
169
+ #### Parameters
170
+
171
+ | Parameter | Type | Description |
172
+ | :------ | :------ | :------ |
173
+ | `predicate` | (`value`) => `boolean` | A function that takes the contained value and returns a boolean. |
174
+
175
+ #### Returns
176
+
177
+ [`Option`](Option.md)\<`T`\>
178
+
179
+ #### Source
180
+
181
+ [enum/prelude.ts:142](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L142)
182
+
183
+ ***
184
+
185
+ ### flatten()
186
+
187
+ ```ts
188
+ flatten<T>(this): Option<T>
189
+ ```
190
+
191
+ Converts from `Option<Option<T>>` to `Option<T>`.
192
+
193
+ #### Type parameters
194
+
195
+ | Type parameter |
196
+ | :------ |
197
+ | `T` |
198
+
199
+ #### Parameters
200
+
201
+ | Parameter | Type |
202
+ | :------ | :------ |
203
+ | `this` | [`Option`](Option.md)\<[`Option`](Option.md)\<`T`\>\> |
204
+
205
+ #### Returns
206
+
207
+ [`Option`](Option.md)\<`T`\>
208
+
209
+ `None` if the Option is `None`, otherwise returns the contained `Option`.
210
+
211
+ #### Source
212
+
213
+ [enum/prelude.ts:148](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L148)
214
+
215
+ ***
216
+
217
+ ### inspect()
218
+
219
+ ```ts
220
+ inspect(fn): this
221
+ ```
222
+
223
+ Calls the provided function with the contained value if `this` is `Some`.
224
+ This is primarily for side effects and does not transform the `Option`.
225
+
226
+ #### Parameters
227
+
228
+ | Parameter | Type | Description |
229
+ | :------ | :------ | :------ |
230
+ | `fn` | (`value`) => `void` | A function to call with the contained value. |
231
+
232
+ #### Returns
233
+
234
+ `this`
235
+
236
+ `this`, unmodified, for chaining additional methods.
237
+
238
+ #### Source
239
+
240
+ [enum/prelude.ts:267](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L267)
241
+
242
+ ***
243
+
244
+ ### isNone()
245
+
246
+ ```ts
247
+ isNone(): boolean
248
+ ```
249
+
250
+ Returns `true` if the Option is a `None` value.
251
+
252
+ #### Returns
253
+
254
+ `boolean`
255
+
256
+ #### Source
257
+
258
+ [enum/prelude.ts:59](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L59)
259
+
260
+ ***
261
+
262
+ ### isSome()
263
+
264
+ ```ts
265
+ isSome(): boolean
266
+ ```
267
+
268
+ Returns `true` if the Option is a `Some` value.
269
+
270
+ #### Returns
271
+
272
+ `boolean`
273
+
274
+ #### Source
275
+
276
+ [enum/prelude.ts:54](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L54)
277
+
278
+ ***
279
+
280
+ ### isSomeAnd()
281
+
282
+ ```ts
283
+ isSomeAnd(predicate): boolean
284
+ ```
285
+
286
+ Returns `true` if the Option is a `Some` value and the predicate returns `true` for the contained value.
287
+
288
+ #### Parameters
289
+
290
+ | Parameter | Type | Description |
291
+ | :------ | :------ | :------ |
292
+ | `predicate` | (`value`) => `boolean` | A function that takes the contained value and returns a boolean. |
293
+
294
+ #### Returns
295
+
296
+ `boolean`
297
+
298
+ #### Source
299
+
300
+ [enum/prelude.ts:65](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L65)
301
+
302
+ ***
303
+
304
+ ### map()
305
+
306
+ ```ts
307
+ map<U>(fn): Option<U>
308
+ ```
309
+
310
+ Maps an `Option<T>` to `Option<U>` by applying a function to a contained value.
311
+
312
+ #### Type parameters
313
+
314
+ | Type parameter | Description |
315
+ | :------ | :------ |
316
+ | `U` | The type of the value returned by the map function. |
317
+
318
+ #### Parameters
319
+
320
+ | Parameter | Type | Description |
321
+ | :------ | :------ | :------ |
322
+ | `fn` | (`value`) => `U` | A function that takes the contained value and returns a new value. |
323
+
324
+ #### Returns
325
+
326
+ [`Option`](Option.md)\<`U`\>
327
+
328
+ #### Source
329
+
330
+ [enum/prelude.ts:155](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L155)
331
+
332
+ ***
333
+
334
+ ### mapOr()
335
+
336
+ ```ts
337
+ mapOr<U>(defaultValue, fn): U
338
+ ```
339
+
340
+ Maps an `Option<T>` to `U` by applying a function to the contained value (if any), or returns the provided default (if not).
341
+
342
+ #### Type parameters
343
+
344
+ | Type parameter | Description |
345
+ | :------ | :------ |
346
+ | `U` | The type of the value returned by the map function or the default value. |
347
+
348
+ #### Parameters
349
+
350
+ | Parameter | Type | Description |
351
+ | :------ | :------ | :------ |
352
+ | `defaultValue` | `U` | The value to return if the Option is `None`. |
353
+ | `fn` | (`value`) => `U` | A function that takes the contained value and returns a new value. |
354
+
355
+ #### Returns
356
+
357
+ `U`
358
+
359
+ #### Source
360
+
361
+ [enum/prelude.ts:163](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L163)
362
+
363
+ ***
364
+
365
+ ### mapOrElse()
366
+
367
+ ```ts
368
+ mapOrElse<U>(defaultFn, fn): U
369
+ ```
370
+
371
+ Maps an `Option<T>` to `U` by applying a function to a contained value (if any), or computes a default (if not).
372
+
373
+ #### Type parameters
374
+
375
+ | Type parameter | Description |
376
+ | :------ | :------ |
377
+ | `U` | The type of the value returned by the map function or the default function. |
378
+
379
+ #### Parameters
380
+
381
+ | Parameter | Type | Description |
382
+ | :------ | :------ | :------ |
383
+ | `defaultFn` | () => `U` | A function that returns the default value. |
384
+ | `fn` | (`value`) => `U` | A function that takes the contained value and returns a new value. |
385
+
386
+ #### Returns
387
+
388
+ `U`
389
+
390
+ #### Source
391
+
392
+ [enum/prelude.ts:171](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L171)
393
+
394
+ ***
395
+
396
+ ### okOr()
397
+
398
+ ```ts
399
+ okOr<E>(error): Result<T, E>
400
+ ```
401
+
402
+ Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to `Ok(v)` and `None` to `Err(err)`.
403
+
404
+ #### Type parameters
405
+
406
+ | Type parameter | Description |
407
+ | :------ | :------ |
408
+ | `E` | The type of the error value in the `Err` variant of the resulting `Result`. |
409
+
410
+ #### Parameters
411
+
412
+ | Parameter | Type | Description |
413
+ | :------ | :------ | :------ |
414
+ | `error` | `E` | The error value to use if the Option is a `None`. |
415
+
416
+ #### Returns
417
+
418
+ [`Result`](Result.md)\<`T`, `E`\>
419
+
420
+ #### Source
421
+
422
+ [enum/prelude.ts:113](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L113)
423
+
424
+ ***
425
+
426
+ ### okOrElse()
427
+
428
+ ```ts
429
+ okOrElse<E>(err): Result<T, E>
430
+ ```
431
+
432
+ Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to `Ok(v)` and `None` to `Err(err())`.
433
+
434
+ #### Type parameters
435
+
436
+ | Type parameter | Description |
437
+ | :------ | :------ |
438
+ | `E` | The type of the error value in the `Err` variant of the resulting `Result`. |
439
+
440
+ #### Parameters
441
+
442
+ | Parameter | Type | Description |
443
+ | :------ | :------ | :------ |
444
+ | `err` | () => `E` | A function that returns the error value. |
445
+
446
+ #### Returns
447
+
448
+ [`Result`](Result.md)\<`T`, `E`\>
449
+
450
+ #### Source
451
+
452
+ [enum/prelude.ts:120](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L120)
453
+
454
+ ***
455
+
456
+ ### or()
457
+
458
+ ```ts
459
+ or(other): Option<T>
460
+ ```
461
+
462
+ Returns the Option if it contains a value, otherwise returns `other`.
463
+ This can be used for providing a fallback `Option`.
464
+
465
+ #### Parameters
466
+
467
+ | Parameter | Type | Description |
468
+ | :------ | :------ | :------ |
469
+ | `other` | [`Option`](Option.md)\<`T`\> | The fallback `Option` to use if `this` is `None`. |
470
+
471
+ #### Returns
472
+
473
+ [`Option`](Option.md)\<`T`\>
474
+
475
+ `this` if it is `Some`, otherwise `other`.
476
+
477
+ #### Source
478
+
479
+ [enum/prelude.ts:241](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L241)
480
+
481
+ ***
482
+
483
+ ### orElse()
484
+
485
+ ```ts
486
+ orElse(fn): Option<T>
487
+ ```
488
+
489
+ Returns the Option if it contains a value, otherwise calls `fn` and returns the result.
490
+ This method can be used for lazy fallbacks, as `fn` is only evaluated if `this` is `None`.
491
+
492
+ #### Parameters
493
+
494
+ | Parameter | Type | Description |
495
+ | :------ | :------ | :------ |
496
+ | `fn` | () => [`Option`](Option.md)\<`T`\> | A function that produces an `Option`. |
497
+
498
+ #### Returns
499
+
500
+ [`Option`](Option.md)\<`T`\>
501
+
502
+ `this` if it is `Some`, otherwise the result of `fn`.
503
+
504
+ #### Source
505
+
506
+ [enum/prelude.ts:249](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L249)
507
+
508
+ ***
509
+
510
+ ### transpose()
511
+
512
+ ```ts
513
+ transpose<T, E>(this): Result<Option<T>, E>
514
+ ```
515
+
516
+ Transposes an `Option` of a `Result` into a `Result` of an `Option`.
517
+
518
+ #### Type parameters
519
+
520
+ | Type parameter | Description |
521
+ | :------ | :------ |
522
+ | `T` | The type of the success value in the `Ok` variant of the `Result`. |
523
+ | `E` | The type of the error value in the `Err` variant of the `Result`. |
524
+
525
+ #### Parameters
526
+
527
+ | Parameter | Type |
528
+ | :------ | :------ |
529
+ | `this` | [`Option`](Option.md)\<[`Result`](Result.md)\<`T`, `E`\>\> |
530
+
531
+ #### Returns
532
+
533
+ [`Result`](Result.md)\<[`Option`](Option.md)\<`T`\>, `E`\>
534
+
535
+ `Ok` containing `Some` if the Option is a `Some` containing `Ok`,
536
+ `Err` containing the error if the Option is a `Some` containing `Err`,
537
+ `Ok` containing `None` if the Option is `None`.
538
+
539
+ #### Source
540
+
541
+ [enum/prelude.ts:130](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L130)
542
+
543
+ ***
544
+
545
+ ### unwrap()
546
+
547
+ ```ts
548
+ unwrap(): T
549
+ ```
550
+
551
+ Returns the contained `Some` value.
552
+
553
+ #### Returns
554
+
555
+ `T`
556
+
557
+ #### Throws
558
+
559
+ Throws an error if the value is a `None`.
560
+
561
+ #### Source
562
+
563
+ [enum/prelude.ts:86](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L86)
564
+
565
+ ***
566
+
567
+ ### unwrapOr()
568
+
569
+ ```ts
570
+ unwrapOr(defaultValue): T
571
+ ```
572
+
573
+ Returns the contained `Some` value or a provided default.
574
+
575
+ #### Parameters
576
+
577
+ | Parameter | Type | Description |
578
+ | :------ | :------ | :------ |
579
+ | `defaultValue` | `T` | The value to return if the Option is a `None`. |
580
+
581
+ #### Returns
582
+
583
+ `T`
584
+
585
+ #### Source
586
+
587
+ [enum/prelude.ts:92](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L92)
588
+
589
+ ***
590
+
591
+ ### unwrapOrElse()
592
+
593
+ ```ts
594
+ unwrapOrElse(fn): T
595
+ ```
596
+
597
+ Returns the contained `Some` value or computes it from a closure.
598
+
599
+ #### Parameters
600
+
601
+ | Parameter | Type | Description |
602
+ | :------ | :------ | :------ |
603
+ | `fn` | () => `T` | A function that returns the default value. |
604
+
605
+ #### Returns
606
+
607
+ `T`
608
+
609
+ #### Source
610
+
611
+ [enum/prelude.ts:98](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L98)
612
+
613
+ ***
614
+
615
+ ### unzip()
616
+
617
+ ```ts
618
+ unzip<T, U>(this): [Option<T>, Option<U>]
619
+ ```
620
+
621
+ Converts from `Option<[T, U]>` to `[Option<T>, Option<U>]`.
622
+ If `this` is `Some([a, b])`, returns `[Some(a), Some(b)]`.
623
+ If `this` is `None`, returns `[None, None]`.
624
+
625
+ #### Type parameters
626
+
627
+ | Type parameter | Description |
628
+ | :------ | :------ |
629
+ | `T` | The type of the first value in the tuple. |
630
+ | `U` | The type of the second value in the tuple. |
631
+
632
+ #### Parameters
633
+
634
+ | Parameter | Type |
635
+ | :------ | :------ |
636
+ | `this` | [`Option`](Option.md)\<[`T`, `U`]\> |
637
+
638
+ #### Returns
639
+
640
+ [[`Option`](Option.md)\<`T`\>, [`Option`](Option.md)\<`U`\>]
641
+
642
+ A tuple of `Options`, one for each element in the original `Option` of a tuple.
643
+
644
+ #### Source
645
+
646
+ [enum/prelude.ts:207](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L207)
647
+
648
+ ***
649
+
650
+ ### xor()
651
+
652
+ ```ts
653
+ xor(other): Option<T>
654
+ ```
655
+
656
+ Returns `Some` if exactly one of `this`, `other` is `Some`, otherwise returns `None`.
657
+ This can be thought of as an exclusive or operation on `Option` values.
658
+
659
+ #### Parameters
660
+
661
+ | Parameter | Type | Description |
662
+ | :------ | :------ | :------ |
663
+ | `other` | [`Option`](Option.md)\<`T`\> | The other `Option` to compare with. |
664
+
665
+ #### Returns
666
+
667
+ [`Option`](Option.md)\<`T`\>
668
+
669
+ `Some` if exactly one of `this` and `other` is `Some`, otherwise `None`.
670
+
671
+ #### Source
672
+
673
+ [enum/prelude.ts:257](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L257)
674
+
675
+ ***
676
+
677
+ ### zip()
678
+
679
+ ```ts
680
+ zip<U>(other): Option<[T, U]>
681
+ ```
682
+
683
+ Combines `this` with another `Option` by zipping their contained values.
684
+ If `this` is `Some(s)` and `other` is `Some(o)`, returns `Some([s, o])`.
685
+ If either `this` or `other` is `None`, returns `None`.
686
+
687
+ #### Type parameters
688
+
689
+ | Type parameter | Description |
690
+ | :------ | :------ |
691
+ | `U` | The type of the value in the other `Option`. |
692
+
693
+ #### Parameters
694
+
695
+ | Parameter | Type | Description |
696
+ | :------ | :------ | :------ |
697
+ | `other` | [`Option`](Option.md)\<`U`\> | The other `Option` to zip with. |
698
+
699
+ #### Returns
700
+
701
+ [`Option`](Option.md)\<[`T`, `U`]\>
702
+
703
+ An `Option` containing a tuple of the values if both are `Some`, otherwise `None`.
704
+
705
+ #### Source
706
+
707
+ [enum/prelude.ts:185](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L185)
708
+
709
+ ***
710
+
711
+ ### zipWith()
712
+
713
+ ```ts
714
+ zipWith<U, R>(other, fn): Option<R>
715
+ ```
716
+
717
+ Zips `this` with another `Option` using a provided function to combine their contained values.
718
+ If `this` is `Some(s)` and `other` is `Some(o)`, returns `Some(fn(s, o))`.
719
+ If either `this` or `other` is `None`, returns `None`.
720
+
721
+ #### Type parameters
722
+
723
+ | Type parameter | Description |
724
+ | :------ | :------ |
725
+ | `U` | The type of the value in the other `Option`. |
726
+ | `R` | The return type of the combining function. |
727
+
728
+ #### Parameters
729
+
730
+ | Parameter | Type | Description |
731
+ | :------ | :------ | :------ |
732
+ | `other` | [`Option`](Option.md)\<`U`\> | The other `Option` to zip with. |
733
+ | `fn` | (`value`, `otherValue`) => `R` | The function to combine the values from both `Options`. |
734
+
735
+ #### Returns
736
+
737
+ [`Option`](Option.md)\<`R`\>
738
+
739
+ An `Option` containing the result of `fn` if both `Options` are `Some`, otherwise `None`.
740
+
741
+ #### Source
742
+
743
+ [enum/prelude.ts:197](https://github.com/JiangJie/happy-rusty/blob/15ed105e08c6cc3943e22243c9386336a521d83e/src/enum/prelude.ts#L197)