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