diff options
author | n5m <72841454+n5m@users.noreply.github.com> | 2020-11-09 10:45:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-09 11:45:43 +0100 |
commit | 3be404af0488805493a46329d35ad276d739151d (patch) | |
tree | 551a0559f4f60d9ffab467c72aa71fab22a0d498 /doc/destructors.rst | |
parent | d03f24147a185091344c67a720a13ca0b3c98dc2 (diff) | |
download | Nim-3be404af0488805493a46329d35ad276d739151d.tar.gz |
include example of error-marked copy proc (#15886)
* include example of error-marked copy proc * Update destructors.rst
Diffstat (limited to 'doc/destructors.rst')
-rw-r--r-- | doc/destructors.rst | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/doc/destructors.rst b/doc/destructors.rst index 66f1043b3..e48e360dd 100644 --- a/doc/destructors.rst +++ b/doc/destructors.rst @@ -184,8 +184,14 @@ The general pattern in ``=copy`` looks like: 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 ============== |