casting
A wrapper for the C++ cast operators
Summary
| Latest Version | 0.2.0 |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-09-02 07:21 |
Tags
Authors
- Hsien-yu Chu
Installation
nimble install casting
choosenim install casting
git clone https://github.com/sls1005/nim-casting
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| casting | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Source
| Repository | https://github.com/sls1005/nim-casting |
|---|---|
| Homepage | https://github.com/sls1005/nim-casting |
| Registry Source | nimble_official |
README
Casting
This wraps the C++ cast operators for the Nim programming language.
Example
from casting import dynamicCast
type
A {.inheritable, pure.} = object
a: int
B = object of A
b: float
var x: B
let p: ptr A = dynamicCast[ptr A](x.addr)
if p.isNil():
echo "failed to cast"
else:
(p[]).a = 1
assert x.a == 1
Note
- Please use the built-in keyword
castif possible. This wrapper should only be used wherecastfails, or is inappropriate to use.
Warning
- Some of the
procs provided by this package allow performing unsafe operations. Please be sure of knowing what you are doing with them.