File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ # Avoids changelog conflicts by assuming additions-only, which is by far the common case.
2+ # In the rare case where branch b1 rebases against branch b2 and both branches
3+ # modified the same changelog entry, you'll end up with that changelog entry
4+ # duplicated, which is easily identifiable and fixable.
5+ /changelog.md merge =union
6+
Original file line number Diff line number Diff line change 1+ ## additions and changes
2+
3+ - Added module ` pointers ` containing ` toUncheckedArray `
Original file line number Diff line number Diff line change 1+ ##[
2+ Convenience procs to deal with pointer-like variables.
3+ ]##
4+
5+ proc toUncheckedArray * [T](a: ptr T): ptr UncheckedArray [T] {.inline .} =
6+ # # Shortcut for `cast[ptr UncheckedArray[T]](a)`, where T is inferred.
7+ # # This allows array indexing operations on `a`.
8+ # # This is unsafe as it returns `UncheckedArray`.
9+ runnableExamples:
10+ var a = @ [10 , 11 , 12 ]
11+ let pa = a[1 ].addr .toUncheckedArray
12+ doAssert pa[- 1 ] == 10
13+ pa[0 ] = 100
14+ doAssert a == @ [10 , 100 , 12 ]
15+ pa[0 ] += 5
16+ doAssert a[1 ] == 105
17+ cast [ptr UncheckedArray [T]](a)
You can’t perform that action at this time.
0 commit comments