move type operation section and remove deepcopy document (#19389)

ref #19173; because deepcopy is not fit for ORC/ARC which was used for spawn and spawn will be removed from compiler
This commit is contained in:
flywind 2022-01-15 18:25:09 +08:00 • committed by GitHub
commit 342b74ef70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 40 deletions

View file

@ -3902,6 +3902,18 @@ the operator is in scope (including if it is private).
Type bound operators are:
`=destroy`, `=copy`, `=sink`, `=trace`, `=deepcopy`.
These operations can be *overridden* instead of *overloaded*. This means that
the implementation is automatically lifted to structured types. For instance,
if the type `T` has an overridden assignment operator `=`, this operator is
also used for assignments of the type `seq[T]`.
Since these operations are bound to a type, they have to be bound to a
nominal type for reasons of simplicity of implementation; this means an
overridden `deepCopy` for `ref T` is really bound to `T` and not to `ref T`.
This also means that one cannot override `deepCopy` for both `ptr T` and
`ref T` at the same time, instead a distinct or object helper type has to be
used for one pointer type.
For more details on some of those procs, see
`Lifetime-tracking hooks <destructors.html#lifetimeminustracking-hooks>`_.