paperclip icon indicating copy to clipboard operation
paperclip copied to clipboard

Apiv2Schema does not work for arrays

Open BoOTheFurious opened this issue 4 years ago • 2 comments

Hello, When I define a struct containing an array:

#[derive(Serialize, Deserialize, Debug, Apiv2Schema)]
pub struct MyStruct {
    pub data: [u8; 4],
}

I've got this compil error:

error[E0425]: cannot find function `raw_schema` in the crate root
1464 |     #[derive(Serialize, Deserialize, Apiv2Schema)]
     |                                      ^^^^^^^^^^^ not found in the crate root

If I put the array in an Option or Vec it works.

So what is the problem ?

Regards,

BoOTheFurious avatar Dec 07 '20 14:12 BoOTheFurious

It seems that all is defined in https://github.com/wafflespeanut/paperclip/blob/master/core/src/v2/schema.rs (fnom line 408) so it should be ok …

Le mar. 8 déc. 2020 à 09:51, Mike Bush [email protected] a écrit :

I think the problem is that Apiv2Schema is not implemented for [u8; 4], that's possible but it's just awkward until rust has const generics https://github.com/rust-lang/rust/issues/44580 at which time we can impl<T, N> Apiv2Schema for [T; N]. Until we can use const generics the implementation needs to be defined for every length of array that you need to use.

That being said, I can't find where impl<T> Apiv2Schema for Vec<T> is defined.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wafflespeanut/paperclip/issues/274#issuecomment-740478685, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARXUXWUUBBMGACAEW5IJUT3STXSH7ANCNFSM4UQRH3IA .

BoOTheFurious avatar Dec 08 '20 15:12 BoOTheFurious

@BoOTheFurious Yeah - I found it right after i sent that message, realised I had no understanding of what was going on and tried to sneakily delete it :D

platy avatar Dec 08 '20 17:12 platy