#![allow(dead_code)] use anchor_lang::prelude::borsh::maybestd::io::Write; use anchor_lang::prelude::*; use borsh::{BorshDeserialize, BorshSerialize}; use safecoin_program::pubkey::Pubkey; // Needed to declare accounts. declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); #[derive(Accounts)] pub struct GenericsTest<'info, T, U, const N: usize> where T: AccountSerialize + AccountDeserialize + Owner + Clone, U: BorshSerialize + BorshDeserialize + Default + Clone, { pub non_generic: AccountInfo<'info>, pub generic: Account<'info, T>, pub const_generic: AccountLoader<'info, FooAccount>, pub const_generic_loader: AccountLoader<'info, FooAccount>, pub associated: Account<'info, Associated>, } #[account(zero_copy)] pub struct FooAccount { pub data: WrappedU8Array, } #[account] #[derive(Default)] pub struct Associated where T: BorshDeserialize + BorshSerialize + Default, { pub data: T, } #[derive(Copy, Clone)] pub struct WrappedU8Array(u8); impl BorshSerialize for WrappedU8Array { fn serialize(&self, _writer: &mut W) -> borsh::maybestd::io::Result<()> { todo!() } } impl BorshDeserialize for WrappedU8Array { fn deserialize(_buf: &mut &[u8]) -> borsh::maybestd::io::Result { todo!() } } impl Owner for WrappedU8Array { fn owner() -> Pubkey { crate::ID } }