std/with support field assign (#14484)

* std/with support filed assign

* add changelog

* add support x.dup.with

* add example

* revert support x.dup.with; add example

* update changelog; fix assignment in parameter

* Update changelog.md

* add example for assignment in parameter

* Remove colon style assign

Co-authored-by: Clyybber <darkmine956@gmail.com>
This commit is contained in:
slangmgh 2020-08-15 07:33:21 +08:00 • committed by GitHub
commit ba042af9cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 12 deletions

View file

@ -148,6 +148,21 @@
- Added `deques.toDeque`, which creates a deque from an openArray. The usage is
similar to procs such as `sets.toHashSet` and `tables.toTable`. Previously,
it was necessary to create an empty deque and add items manually.
- `std/with`, `sugar.dup` now support object field assignment expression:
```nim
import std/with
type Foo = object
x, y: int
var foo = Foo()
with foo:
x = 10
y = 20
echo foo
```
## Language changes
- The `=destroy` hook no longer has to reset its target, as the compiler now automatically inserts