You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 10, 2025. It is now read-only.
Array with length of constant expression cannot derive Serializable #144
Hello, I'm using this crate for creating a plugin system for my editor application.
I have added matrix structs with deriving Serializable as:
#[repr(C)]#[derive(Debug,Default,Clone,Copy,PartialEq,Serializable)]pubstructMat2x2{pubcomponents:[f64;2*2],}#[repr(C)]#[derive(Debug,Default,Clone,Copy,PartialEq,Serializable)]pubstructMat2x3{pubcomponents:[f64;3*2],}// :// :#[repr(C)]#[derive(Debug,Default,Clone,Copy,PartialEq,Serializable)]pubstructMat4x4{pubcomponents:[f64;4*4],}// Actually, all combinations of rows and columns are made by `paste!` and my macro. So I don't want to inline them manually if possible.
But it doesn't work against the intention and shows this error (formatted):
It seems that Serializable cannot be derived by the fixed array with length of using const variable too. According to the behaviour of parsing, it is like not to accept except an integer literal.
Activity
arendjr commentedon Sep 19, 2022
I believe currently it only works if you use an integer literal for your dimension (see for example: https://github.com/fiberplane/fp-bindgen/blob/main/examples/example-protocol/src/main.rs#L64). But we don't evaluate other types of expressions.
I'll leave this open as a feature request, but I'm not sure how difficult this would be to implement, to be honest.