tborrowmagic.nim 177 B

123456789
  1. type
  2. Bytes = distinct seq[byte]
  3. proc add(x: var Bytes; b: byte) {.borrow.}
  4. var x = @[].Bytes
  5. x.add(42)
  6. let base = cast[seq[byte]](x)
  7. doAssert base.len == 1 and base[0] == 42