include example of error-marked copy proc (#15886)
* include example of error-marked copy proc * Update destructors.rst
This commit is contained in:
parent
d03f24147a
commit
3be404af04
1 changed files with 7 additions and 1 deletions
|
|
@ -184,8 +184,14 @@ The general pattern in ``=copy`` looks like:
|
||||||
|
|
||||||
|
|
||||||
The ``=copy`` proc can be marked with the ``{.error.}`` pragma. Then any assignment
|
The ``=copy`` proc can be marked with the ``{.error.}`` pragma. Then any assignment
|
||||||
that otherwise would lead to a copy is prevented at compile-time.
|
that otherwise would lead to a copy is prevented at compile-time. This looks like:
|
||||||
|
|
||||||
|
.. code-block:: nim
|
||||||
|
|
||||||
|
proc `=copy`(dest: var T; source: T) {.error.}
|
||||||
|
|
||||||
|
but a custom error message (e.g., ``{.error: "custom error".}``) will not be emitted
|
||||||
|
by the compiler. Notice that there is no ``=`` before the ``{.error.}`` pragma.
|
||||||
|
|
||||||
Move semantics
|
Move semantics
|
||||||
==============
|
==============
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue