1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: support short struct update syntax {...ident, (#8613)

This commit is contained in:
Nick Treleaven
2021-02-07 02:43:51 +00:00
committed by GitHub
parent b92f980274
commit cd4f7101f7
3 changed files with 8 additions and 3 deletions

View File

@ -1633,6 +1633,8 @@ Only more complex types such as arrays and maps may be modified.
Use `user.register()` or `user = register(user)`
instead of `register(mut user)`.
#### Struct update syntax
V makes it easy to return a modified version of an object:
```v
@ -1644,7 +1646,7 @@ struct User {
fn register(u User) User {
return {
u |
...u
is_registered: true
}
}