summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2023-06-27 12:55:47 +0200
committerGitHub <noreply@github.com>2023-06-27 12:55:47 +0200
commitd52b1d848e6e402971e9bd81e58f6d2553854372 (patch)
tree26fae8af0a97669059161421d8fd1a4a18604a3b
parent47635d30315595fc2dbe2162b691aff0f8e0f459 (diff)
downloadNim-d52b1d848e6e402971e9bd81e58f6d2553854372.tar.gz
destructors: update, =destroy does not require a 'var T' (#22168)
-rw-r--r--doc/destructors.md6
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/destructors.md b/doc/destructors.md
index 789cb93d6..12def0053 100644
--- a/doc/destructors.md
+++ b/doc/destructors.md
@@ -36,7 +36,7 @@ written as:
       len, cap: int
       data: ptr UncheckedArray[T]
 
-  proc `=destroy`*[T](x: var myseq[T]) =
+  proc `=destroy`*[T](x: myseq[T]) =
     if x.data != nil:
       for i in 0..<x.len: `=destroy`(x.data[i])
       dealloc(x.data)
@@ -256,10 +256,10 @@ The general pattern in using `=destroy` with `=trace` looks like:
     Test[T](size: size, arr: cast[ptr UncheckedArray[T]](alloc0(sizeof(T) * size)))
 
 
-  proc `=destroy`[T](dest: var Test[T]) =
+  proc `=destroy`[T](dest: Test[T]) =
     if dest.arr != nil:
       for i in 0 ..< dest.size: dest.arr[i].`=destroy`
-      dest.arr.dealloc
+      dealloc dest.arr
 
   proc `=trace`[T](dest: var Test[T]; env: pointer) =
     if dest.arr != nil: