What am I doing wrong? Is that not how we use tuples in rust?
Account:
#[account]
pub struct UserLedger {
pub list: Vec<(String, u32)>,
}
Error Message:
Error: Type not found: {"type":{"defined":"(String,u32)"}}
What am I doing wrong? Is that not how we use tuples in rust?
Account:
#[account]
pub struct UserLedger {
pub list: Vec<(String, u32)>,
}
Error Message:
Error: Type not found: {"type":{"defined":"(String,u32)"}}
tuples are not implemented in anchor so far (version: 0.27.0
at time of writing), you can use a struct
in your case.
#[account]
pub struct UserLedger {
pub list: Vec<MyTuple>,
}
#[derive(AnchorSerialize, AnchorDeserialize)]
struct MyTuple {
my_string: String,
my_u32: u32
}
for an enum
as well you are not allowed to use tuples, which is quite common, but you can use it like this:
#[derive(AnchorSerialize, AnchorDeserialize)]
pub enum Grade {
Pass { value: u64 },
Fail { value: u64, next_attempt: MyDate },
}
pub list: Vec<(String, u32)>
should be pub list: Vec<MyTuple>
? `
Commented
Apr 21, 2023 at 14:36