Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don’t do Rust but that was nicely readable. One comment: using Enums for stock symbols presumably forces a recompile on each new symbol. What would be the idiomatic representation in Rust for things like that? Some kind of interned string?


A string works. If a numerical/in-place representation is wanted for efficiency, you could rely on the fact that stock symbols are always less than 8 characters, so we can parse it into an array of 8 bytes.


Is wrapping a String in a semi-opaque newtype (or a type alias at least) good to encode the semantic meaning of the string type?


Actually they are definitely not always <= 8 characters, but usually they are.




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

Search: