Duralf

joined 2 years ago
[–] [email protected] 1 points 1 year ago

Even in C this is possible. Just wrap the float or whatever in a struct and all implicit conversions will be gone.

[–] [email protected] 1 points 1 year ago (4 children)

API from a call that accepted integer values between 0 and 32767 (minimum and maximum wheel speeds) to one that accepted float values between 0.0 and 1.0.

This would cause alarm bells to ring in my head for sure. If I did something like that I would make a new type that was definitely not implicitly castable to or from the old type. Definitely not a raw integer or float type.

[–] [email protected] 1 points 2 years ago

Atomic instructions are quite slow and if they run a lot... Rust has two types of reference counted pointer for that reason. One that has atomic reference counting for multithreaded code and one non-atomic for single threaded. Reference counting is usually overkill in the first place and can be a sign that your code doesn't have proper ownership.