2 ms·
One of the things the author neglects is the ease of use of newtypes in Rust. This can actually alleviate a lot of parsing issues, by making it impossible to us
by jcranmer 6y ago
One of the things the author neglects is the ease of use of newtypes in Rust. This can actually alleviate a lot of parsing issues, by making it impossible to use stuff without parsing.
An example of where I've recently done something like this is my sparse linear algebra code. I have distinct types for column and row vectors for a matrix, so that if I want to right-multiply A with a vector, the input has to be a column vector and the output has to be a row vector. Similarly, if I want to left-multiply A with a vector, the input has to be a row vector and the output has to be a column vector.
- p-squared 6y agoMaybe Rust makes newtypes _easy_, but certainly C supports similar idioms by way of wrapping data in a unique struct.
- steveklabnik 6y agoThe only significant difference is that you have to give the inner value a name in C, but you don't in Rust. It's a pretty marginal advantage.