Make add work in the destructors example (#17354)

This commit is contained in:
Clyybber
2021-03-15 13:03:00 +01:00
committed by GitHub
parent 5c49480d8c
commit 283d9abc84

View File

@@ -62,7 +62,9 @@ written as:
a.data = b.data
proc add*[T](x: var myseq[T]; y: sink T) =
if x.len >= x.cap: resize(x)
if x.len >= x.cap:
x.cap = max(x.len + 1, x.cap * 2)
x.data = cast[typeof(x.data)](realloc(x.data, x.cap * sizeof(T)))
x.data[x.len] = y
inc x.len