File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -375,6 +375,9 @@ in the `for` loop and the desugaring as per the section on grammar.
375
375
376
376
## Desugaring ` let ` statements with ` | ` in the top-level pattern
377
377
378
+ There continues to be an exhaustivity check in ` let ` statements,
379
+ however this check will now be able to support multiple patterns.
380
+
378
381
This is a possible desugaring that a Rust compiler may do.
379
382
While such a compiler may elect to implement this differently,
380
383
these semantics should be kept.
@@ -404,6 +407,48 @@ Result
404
407
}
405
408
```
406
409
410
+ For example, the following code:
411
+
412
+ ``` rust
413
+ {
414
+ foo ();
415
+ bar ();
416
+ let Ok (index ) | Err (index ) = slice . binary_search (& thing );
417
+ println! (" {}" , index );
418
+ do_something_to (index )
419
+ }
420
+ ```
421
+
422
+ can be desugared to
423
+
424
+ ``` rust
425
+ {
426
+ foo ();
427
+ bar ();
428
+ match slice . binary_search (& thing ) {
429
+ Ok (index ) | Err (index ) => {
430
+ println! (" {}" , index );
431
+ do_something_to (index )
432
+ }
433
+ }
434
+ }
435
+ ```
436
+
437
+ It can also be desugared to:
438
+
439
+ ``` rust
440
+ {
441
+ foo ();
442
+ bar ();
443
+ let index = match slice . binary_search (& thing ) {
444
+ Ok (index ) | Err (index ) => index ,
445
+ }
446
+ println! (" {}" , index );
447
+ do_something_to (index )
448
+ }
449
+ ```
450
+
451
+ (Both are equivalent)
407
452
# Drawbacks
408
453
[ drawbacks ] : #drawbacks
409
454
You can’t perform that action at this time.
0 commit comments