Are there any creates that help serialize Rust types as correctly formatted Rust code? It'd help enormously when defining tables used in cryptography or other arithmetic computations.
It should produce const/static declarations of course, so it'd require a translation from non-
'static types to
'static types, and should fail when this fails.
As a type level example, if
T could be converted to
Cow<'a,T> should be replaced by
Cow<'static,T>. At the value level, both
Cow::Borrowed(&'a [T]) should be replaced by
There exist more complex forms in which you translate names so that
Box<[T]> simple become
&static [T] directly, but this plays less well than
Cow with the same code being used both at runtime and at pre-compile time.
In principle, you could serialize types containing allocations like
Box<T> into code that first creates the
Box<T>, but doing so appears largely useless since other serializations operate more efficiently once you require decoding anyways.