reinterpretcat / vrp

A Vehicle Routing Problem solver
https://reinterpretcat.github.io/vrp/
Apache License 2.0
331 stars 68 forks source link

Unsound `From` implementation for `ObservationData` #110

Closed shinmao closed 1 year ago

shinmao commented 1 year ago

https://github.com/reinterpretcat/vrp/blob/b06c714f4598dad70b2410fb6fa8f0798d559efb/experiments/heuristic-research/src/solver/proxies.rs#L37-L51 Implementation with reference transmute are unsound at line 44 and line 51. If we transmute reference, we need to guarantee the layout of types by ourselves. None of trait bound on S can make a safe guarantee. Even line 42 and line 49 can check the same type id, we still can't guarantee struct instances with same definition have same layout because repr(Rust) is not specified representation.

reinterpretcat commented 1 year ago

Hi, heuristic-research crate, as name suggests, is experimental crate to check some ideas. It is not used by the VRP solver itself and never will be. So, I accept some unsafe code here if it helps to simplify implementation a lot.