Hacker News new | past | comments | ask | show | jobs | submit login

> How expensive is this kind of casting in Rust?

It really depends on how you're implementing it. If you're doing a clone/deepcopy-style conversion, or if you're consuming the value you're casting from. However, since most values in Rust are placed on the stack, "allocating" them is incredibly cheap. Moving them around is often also cheap, and involves just a few `mov`s from registers to registers, or stack-address to stack-address.

A very simple example: https://godbolt.org/z/WMePqMd71




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: