Custom Default trait on user-defined IDL structs
losman0s opened this issue · comments
Is there a way to handle custom Default trait definition for some of the Defined structs, e.g.:
{
"name": "MyStruct",
"type": {
"kind": "struct",
"fields": [
{
"name": "authority",
"type": "publicKey"
},
{
"name": "reservedSpace",
"type": {
"array": ["u128", 256]
}
}
]
}
}
atm the explicit sizes (0-32) in the standard implementation prevents generation:
the trait 'Default' is not implemented for '[u128; 256]'
Not sure if notifications go through so will try pinging @macalinao
This specific case is fixed. We should probably add a way to explicitly specify that a Default should not be generated for a type though
This specific case is fixed. We should probably add a way to explicitly specify that a Default should not be generated for a type though
Great thanks! One last clarification though: I don't get the use case for the separation between anchor_gen::generate_cpi_crate
and anchor_gen::generate_cpi_interface
. The former, shown in the README
, seems to only be a "forced defaults" of the latter.
- Am I missing something
- If not, it might be valuable to avoid confusion by either explaining the distinction, or using
anchor_gen::generate_cpi_interface
in teh README (although I agree examples are pretty helpful in any case)
Backwards compatibility. Maybe we should mark the other one as deprecated