linebender / kurbo

A Rust library for manipulating curves
Apache License 2.0
716 stars 69 forks source link

Support for no-alloc #327

Closed jneem closed 9 months ago

jneem commented 11 months ago

A surprising amount of useful kurbo code doesn't require allocation (which is really only used for BezPath and its dependents). This adds a feature for turning off allocation support altogether.

Note that this change might break anyone who uses kurbo with default-features = false.

xStrom commented 9 months ago

There was a tiny bit of discussion about this PR during office hours and a question that came up was the use case. I'm relaying that here to help move this forward.

Could you describe your use case a bit where no-alloc is beneficial? No need for a massive rationale, but because this does add a bit of complexity to the code and testing, it would be useful to have a bit more specifics about the benefits.

For extra context @longmathemagician pointed out in Zulip that dynamic allocation is disallowed in aerospace (DO-178B) but also automotive (MISRA C / ISO 26262) and functional safety applications (IEC 61508).

jneem commented 9 months ago

Ah, sorry, I replied on the zulip before seeing this comment. I'm using kurbo on an esp32c3 device, using esp-hal which doesn't support alloc out-of-the-box. It's quite possible that this is too niche to be worth supporting upstream, in which case I'm quite happy to maintain my own patchset.

jneem commented 9 months ago

I've done some more experimentation, and I think I'm better off switching to euclid and lyon_geom for the embedded part. They already have no-alloc (and f32) support, and the conversions aren't too painful.