尝试通过 Solana 程序构建时,出现此错误。谁能告诉我如何序列化字符串,因为我在我的结构中使用字符串。或者,如果在 Solana 程序中无法序列化字符串,我应该使用什么来代替 String?
结构:盒子
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize, PartialEq)]
pub struct Box {
pub token_uris: [String; 3],
pub count: i32,
pub title: String,
pub description: String,
pub image: String,
pub price: i32,
pub usd_price: i32,
pub count_nft: i32,
pub is_opened: bool,
}
错误日志:
15 | #[derive(Clone, Debug, BorshSerialize, BorshDeserialize, PartialEq)]
| ^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String`
|
= note: required because of the requirements on the impl of `AnchorDeserialize` for `[std::string::String; 3]`
= help: see issue #48214
= note: this error originates in the derive macro `BorshDeserialize` (in Nightly builds, run with -Z macro-backtrace for more info)