Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think the trick of using a separate file per target works just as well in Rust, where each one imports the appropriate HAL(s) and they all expose the same interface as each other. “Circular” imports across the files should work too. This will help reduce/resolve the scattering of #[cfg]s throughout the code (but won’t help with the heterogeneous iteration).

Another approach for that sort of genericity would be a trait that is implemented for each target. This ends up being a more formal/structured version of the above, since it defines the interface explicitly, but is potentially over engineering.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: