sile / patricia_tree

A memory-efficient patricia tree implementation written in Rust
MIT License
113 stars 17 forks source link

WIP: Remove lots of unsafe from Node #7

Closed leshow closed 4 years ago

leshow commented 4 years ago

Not sure if this is of interest to you, but I was able to remove large amounts of unsafe from Node. I used your benchmarks, and it runs about the same speed on my machine as before.

There are a few caveats:

The parts that really worried me were the un-aligned allocation combined with ptr::write which the std lib says causes UB. the use of transmute_copy too, which the docs say is one of the most unsafe things you can do, and could be error prone in edge cases.

leshow commented 4 years ago

I need to commit other things to master, I will re-open later if there is interest