3 ms·
The docs say it's largely complete. As an example of a headache, one node type in Judy has a count, followed by that many index bytes, followed by the same num
by twic 6y ago
The docs say it's largely complete.
As an example of a headache, one node type in Judy has a count, followed by that many index bytes, followed by the same number of pointers. In Rust, that would naturally be a struct with two variable-sized fields, which isn't possible, so it's done by defining a struct generic over a pair of array types:
https://github.com/adevore/rudy/blob/300f2cc7842f6329a76fff012056f54bf6a37424/src/util/locksteparray.rs#L81 https://github.com/adevore/rudy/blob/300f2cc7842f6329a76fff0...
It looks to me like this is only ever instantiated for 2, 7, or 31 elements, whereas i think for original Judy, it can be any size up to 31 elements (maybe?). Handling a genuinely variable length in Rust would be rather gnarly, because there have to be different types for each length.
- quicknir 6y agoI would assume that within unsafe you could simply do the same kinds of shenanigans you would do in C++, e.g. you have a fixed size struct that is just the "header", it's only created on the heap, and it's immediately followed by the variable amount of data which you get access to by casting. If you couldn't do this in unsafe rust this seems like a pretty huge limitation.
- steveklabnik 6y agoYes, you could.