The goal is to use to use the char type.
I couldn't find a way or ressource on how to solve to borsh serialization errors that get thrown when trying to store a char type in an #[account] struct field.
Other types or enums won't make problems.
A reproduction is as simple as taking any anchor project and defining one of the fileds of an account to be type of char
. E.g. when using one of the example projects from the anchor repo and adding a char field it will produce an error:
#[account]
pub struct Counter {
pub authority: Pubkey,
pub count: u64,
pub something: char, // <- will produce error
}
To take an example from one of the projects I'm working on:
Error msg:
rustc: the trait bound `char: BorshSerialize` is not satisfied
the following other types implement trait `BorshSerialize`:
&T
()
(T0, T1)
(T0, T1, T2)
(T0, T1, T2, T3)
(T0, T1, T2, T3, T4)
(T0, T1, T2, T3, T4, T5)
(T0, T1, T2, T3, T4, T5, T6)
and 185 others
see issue #48214
Also trying to use a char as a function argument throws errors for the #[program] macro.
Project in screenshots: https://github.com/tobealive/anchor-solana-twitter/