3 ms·
Zero-allocation Rust is quite idiomatic. I write some every day :)
by steveklabnik 6y ago
Zero-allocation Rust is quite idiomatic. I write some every day :)
- theamk 6y agoMaybe "not ideomatic" is not quite the right word... They are explicitly making their API more complex in order to support unusual usages. They avoid heap allocation by making user pre-allocate output buffers. And they even avoid stack allocation by having user provide "void* tmp" argument (see [0]). One can definitely implement such interface in Rust, but I don't think it would be pleasant to use. Having to worry about temp buffer allocation at most calls is not something one wants to do. I am pretty sure that this library is designed to be wrapped by a second layer -- be it in Rust, C++ or even GLib-style C. [0] https://falcon-sign.info/impl/falcon.h.html https://falcon-sign.info/impl/falcon.h.html
- steveklabnik 6y agoTaking a mutable slice is extremely common for exactly this reason. Even in the standard library, which can allocate. We added some convenient functions later, but it's a pretty standard practice.