Skip to content

Commit

Permalink
destructors: update, =destroy does not require a 'var T' (#22168)
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq authored Jun 27, 2023
1 parent 47635d3 commit d52b1d8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/destructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d52b1d8

Please sign in to comment.