Update Examples

Glen Whitney 2024-08-26 16:25:57 +00:00
parent 9e4b317101
commit 9137e43f90

@ -987,3 +987,21 @@ fn main
```
</td></tr></table>
#### match
There's not really much new Husht-syntax-wise in this section. However, it does raise the challenge of destructuring a nested struct. Suppose Foo has fields bar of type Bar and baz of type Baz, and further each of Bar and Baz have fields x and y. Then the full destructure of a Foo might look like:
```
let Foo bar: Bar x: x1, y: y1, baz: Baz x: x2, y: y2 = aFoo
```
Is this really parseable? It seems not; what if Bar also had a Baz field named baz? There's no way for the parser to tell short of analyzing the types. So it seems some braces or linebreaks are necessary. Husht will allow either of course. So you could write:
```
let Foo bar: Bar {x: x1, y: y1}, baz: Baz x: x2, y: y2 = aFoo
```
or
```
let Foo
bar: Bar x: x1, y: y1
baz: Baz x: x2, y: y2
= aFoo
```
as the spirit moves you.