Updated NEP 2 Catching up with C and Rust: Ownership, destructors, unique pointers (markdown)
This commit is contained in:
parent
1ccb39e3cf
commit
802e928737
|
@ -50,5 +50,12 @@ proc `=`(dst: var MyType; src: MyType) =
|
|||
dst.resources = src
|
||||
```
|
||||
|
||||
I just heard, that self assignment on types that have deinitialization would not work anymore. This can be handled by implementing some logic that checks weather it is selft assignment, or by simply declaring self assignment illegal. One version that works with self assignment is the following (again in psoudocode), but it still needs to explain what move semantics are.
|
||||
|
||||
```Nim
|
||||
proc `=`(dst: var MyType; src: MyType) =
|
||||
tmp <- copy(src)
|
||||
destroy(dst)
|
||||
dst <- tmp
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in New Issue