Heh, I also released my first project in Rust yesterday. An ncurses gopher client. I probably missed many patterns and idioms as well. Starting with Rust is quite hard, even as an experienced developer. I spent hours "fighting" the compiler. Code available at https://github.com/jansc/ncgopher/
Async/await syntax is poorly documented across the ecosystem but has landed now and is useful, without it codebases will look outdated soon enough, hyper itself has some of the best docs
Lazystatic is popular way to use globals like that yet don't really bother with it anymore. The paradigms are a bit different for a language, you are discouraged from such things for a reason, there's certainly ways around using globals.
You don't need extern crate with 2018 edition and macros are automatically imported
If this is intended as anything more than a toy, you don't want to store the full OpenLimitOrder in the book data structure.
The symbol should be allocated once on the book. The side is allocated twice in each set of vecs. The price is defined in the vec itself. The queue should be a vec of IDs and open size. The real struct should only be constructed lazily as absolutely needed.
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.
Not the OP, but presumably to minimise the amount of jumping around in memory. Best orderbook is a small matrix, if you can get away with it (for trading you often don't need the whole orderbook, or at least don't need the whole thing on the hot path, but for an exchange obviously there's less scope for approximations).
[+] [-] jansc|6 years ago|reply
[+] [-] kenshi|6 years ago|reply
Can you identify any idioms or approaches that seem normal or natural in other languages, but which are problematic in Rust?
[+] [-] cstein2|6 years ago|reply
[+] [-] ShorsHammer|6 years ago|reply
Async/await syntax is poorly documented across the ecosystem but has landed now and is useful, without it codebases will look outdated soon enough, hyper itself has some of the best docs
Lazystatic is popular way to use globals like that yet don't really bother with it anymore. The paradigms are a bit different for a language, you are discouraged from such things for a reason, there's certainly ways around using globals.
You don't need extern crate with 2018 edition and macros are automatically imported
[+] [-] Misdicorl|6 years ago|reply
The symbol should be allocated once on the book. The side is allocated twice in each set of vecs. The price is defined in the vec itself. The queue should be a vec of IDs and open size. The real struct should only be constructed lazily as absolutely needed.
[+] [-] cstein2|6 years ago|reply
[+] [-] asplake|6 years ago|reply
[+] [-] roblabla|6 years ago|reply
[+] [-] aloukissas|6 years ago|reply
[+] [-] evdubs|6 years ago|reply
[+] [-] cstein2|6 years ago|reply
[+] [-] evdubs|6 years ago|reply
[+] [-] logicchains|6 years ago|reply
[+] [-] globular-toast|6 years ago|reply