stellar / soroban-examples

Example Soroban Contracts
Apache License 2.0
65 stars 68 forks source link

Remove derive Default #243

Closed leighmcculloch closed 1 year ago

leighmcculloch commented 1 year ago

What

Remove #[derive(Default)] from custom structs in examples.

Why

The Default trait's usefulness in contracts is limited because SDK types such as Vec, BytesN, etc cannot implement it. Deriving Default on a UDT requires all its field's types to also implement Default. Using it in an example sets developers up for encountering compile errors when they start adding SDK types to the UDT. The Default trait isn't utilized by the example in any way other than deriving it, so the derive is unnecessary.

Thanks @tomerweller for identifying this issue.

gitpod-io[bot] commented 1 year ago