I've been working on slowly converting an existing C project into rust code. It's been going well for the most part, until I ran into some global statics I have to export for the old C code temporarily until I can remove the need for them.
Declaring and exporting the statics for FFI use was straightforward, but providing them with the required default value has been painful. Initially I thought all I had to do was "impl Default" for the various types found within the static struct. However, that led me to errors like this one:
error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants --> project\src\main.rs:60:20 | 60 | somefield: Default::default(), | ^^^^^^^^^^^^^^^^^^
My understanding is that this is because trait functions currently can't be const in stable rust, so I can't make my fn default() const.
How do others work around this? Is there a workaround or do I just have to live with manually specifying the values of every field in every static struct?