Hello there,
I already tried it via IRC, but maybe, it's a too subjective question for IRC.
I've written and keep writing an API (Diesel (Postgres), Nickel) in Rust. The API is doing a lot of financial calculations. In these calculations, I often search for parameters. The parameters are mostly bound to different presets, etc. So I got a BTreeSet of parameters, found for a unique preset_id. These parameters have boundaries, maybe the height of a container.
Example: I want to find a specific parameter that matches as a range the height of the container. There are a dozen parameters. Starting from height: 100
... ending with height: 1200
(delta of steps is 100). A container has height: 574
. Now I want to find the parameter, that matches the container. As the parameter has a height_from
property, I try to find parameter { height_from: 500 ...}
.
So what's the most elegant way to do this?
I've tried to represent this via a gist on playground, but as you can see, I just bloated the code up massively up, while trying to implement this via Trait:
In the past, I indexed the parameters via a BTreeMap. But that's imho not possible, if I search for parameters with boundaries.
Thanks in advance!