We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
cast
1 parent a24a381 commit 33c2a8dCopy full SHA for 33c2a8d
changelog.md
@@ -1,3 +1,3 @@
1
## additions and changes
2
3
-- Added module `pointers` containing `toUncheckedArray`
+- Added module `pointers` containing `toUncheckedArray`, UFCS/MCS `cast`
src/fusion/pointers.nim
@@ -15,3 +15,11 @@ proc toUncheckedArray*[T](a: ptr T): ptr UncheckedArray[T] {.inline.} =
15
pa[0] += 5
16
doAssert a[1] == 105
17
cast[ptr UncheckedArray[T]](a)
18
+
19
+proc `cast`*[T](a:T, T2: typedesc): T2 =
20
+ ## allows running `cast` in UFCS/method call syntax chains.
21
+ ## Unsafe as it calls `cast`.
22
+ runnableExamples:
23
+ proc square(a: auto): auto = a*a
24
+ doAssert 3.square.cast(float).square == cast[float](3.square).square
25
+ cast[T2](a)
0 commit comments