stellar / rs-soroban-sdk

Rust SDK for Soroban contracts.
Apache License 2.0
123 stars 67 forks source link

Remove need for Copy on error enums #1292

Closed leighmcculloch closed 3 weeks ago

leighmcculloch commented 3 months ago

What

Remove need for Copy/Clone/etc on error enums and int enums.

Why

Less compiler errors for folks just getting started.

The generated code currently requires that error enums impl the Copy trait because they use a copy within. That copy is unnecessary and this change removes it, removing the need for Copy to be derived on error enums.

I was confident that the copy had been put there as an optimisation, but when I looked into the code that was relying on it I found not optimisation was in use. When I tried to add the optimisation, I couldn't find a contract size difference.

A while ago we in https://github.com/stellar/rs-soroban-sdk/pull/1293 added better error messages for needing copy, which was a good fix at the time, I just think we can remove the need for this all together.

Close #630