You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 21, 2024. It is now read-only.
The method takes contract_class: &ContractClass and then clone it.
I think it should be contract_class: ContractClass because it would spare one clone. The ContractClass should be taking ownership of the ContractClass. The current implem adds an unnecessary clone if the lib a caller has a ContractClass for which he doesn't want to keep ownership after the call to ClassInfo::new.
The only reason I see to have the current implem is to spare a clone (in the case the lib caller needs to clone, which we can't know for sure) and that the conditions are not met, making ClassInfo::new return an error.
Even given this, I don't think we should arbitrage in this direction. It looks like a bad design to take a ref and later clone. If you end up needing the value ownership, take it from the get-go
The method takes
contract_class: &ContractClassand thencloneit.I think it should be
contract_class: ContractClassbecause it would spare one clone. TheContractClassshould be taking ownership of theContractClass. The current implem adds an unnecessarycloneif the lib a caller has aContractClassfor which he doesn't want to keep ownership after the call toClassInfo::new.The only reason I see to have the current implem is to spare a
clone(in the case the lib caller needs to clone, which we can't know for sure) and that the conditions are not met, makingClassInfo::newreturn an error.Even given this, I don't think we should arbitrage in this direction. It looks like a bad design to take a ref and later clone. If you end up needing the value ownership, take it from the get-go