milibopp / acacia

A spatial partitioning and tree library in Rust.
Mozilla Public License 2.0
83 stars 8 forks source link

Abstract over Vec as the sole container type #42

Open milibopp opened 9 years ago

milibopp commented 9 years ago

Both the Partition trait and the structs Tree and PureTree could benefit from not being specialized to Vec as a container type for subdivision/branching. Some obvious types to use are [T; 2], [T; 4] and [T; 8]. The cube map partition could use a specialized hybrid container type that can hold either six (dividing the top-level sphere) or four elements (the per-side quad trees). This would also enable using lazy structures such as iterators or any kind of lazily initialized container/sequence.

milibopp commented 9 years ago

It looks like this requires some kind of HKT, which (luckily) can be emulated with associated types. However, there is some issue resolving self-referential trait bounds, which are also required. I started working on this on a branch.

Note, that this can only be thought of as a workaround until Rust gains HKT and will therefore have to be changed at some point. It may be possible to do this backwards-compatibly, while deprecating the hacky bits of it.