near / borsh

Binary Object Representation Serializer for Hashing

Home Page:https://borsh.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Derive failure for `&[T]`

bowenwang1996 opened this issue · comments

If I have the following structs

#[derive(BorshSerialize]
struct A {}
#[derive(BorshSerialize)]
struct B<'a> {
  a: &'a [A]
}

The derive for B will fail even though we have derive for [T] and &T if T implements BorshSerialize. It fails with "size for value cannot be known at compile time. If I change [A] to Vec<A>, it works.

I think BorshSerialize requires Sized, but we probably can lift this requirement. You still need it for BorshDeserialize