Open armaniferrante opened 2 years ago
+1 This would be huge
I have an arrayvec-like implementation here: https://github.com/smartcontractkit/chainlink-solana/blob/develop/contracts/crates/arrayvec/src/lib.rs
Had to strip out the generics (and define the type outside the macro) to make the IDL generator happy.
We should create zero copy collections so that we can use vec, map, etc in zero copy types.
it's worth noting these types are not Copy
, and the ZeroCopy
trait does have an explicit Copy
bound:
pub trait ZeroCopy: Discriminator + Copy + Clone + Zeroable + Pod { }
what do you think of dropping the explicit Copy
bound to make this possible?
bytemuck
's Pod
also includes this bound, but it can be unsafe impl
'dThere's a good reason for this: https://github.com/Lokathor/bytemuck/issues/87#issuecomment-1007577400
There's a good reason for this: Lokathor/bytemuck#87 (comment)
i understand why Pod
needs it, but you can unsafe impl Pod
. here to satisfy #[account(zero_copy)]
we would additionally need something like unsafe impl Copy
which doesn't exist
nvm, i was totally wrong here. bytemuck
will yell at you if you unsafe impl Pod
without the type being Copy
. i had a misunderstanding about unsafe impl Pod
vs. #[derive(Pod)]
but saw in the source the macro is generating unsafe impl
. sorry
We should create zero copy collections so that we can use vec, map, etc in zero copy types.