Skip to content

jnordwick/anycast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anycast

version 0.0 (this will never need versioning so don’t worry about it)

I got tired of the endless casting in zig especially after the type arguemnts was removed from the casting functions in favor of using the expected return type. This can often lead to this string of verbose unnecessary casts, so I have slowly beed adding casting to this single casting function.

Will this cause bugs? Probably. It is a “do what I say and don’t questions my authority” kind of thing. If you want to cast that bool into a float, it will trust you.

It will make it easier to do pointer and bit manipulation.

Future Direction

There is no direction. I just add them as I need them, and if you want me to add something either post a PR or message me on reddit and I’ll see what I can do.

I do want to add zero-cost lvalue casts though since I find it quite annoying.

More to come… maybe… or not… but likely… kinda likely.

Currently Supported

int, float, bool, enum -> int, float, bool, enum
int, ptr -> int, ptr
struct -> struct, int
optional -> optional

Examples

cast(u32, 1243.4)
cast(bool, 123)
cast([*]u32, "asfd")

About

One cast to rule them all

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages