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
Here's esoteric regarding generic function specialization for any Move gurus out there.
I have a function that is mostly Coin type generic. Most of the function applies generically to any coin type, except for one small step in the middle of the function that depends on the concrete coin type. Any advice on how to implement this?
I've only found two options:
A. Add a type_info check [1] to disambiguate the type, which feels gross
B. Forget about about generic types and just have a full copy of the function for each coin type supported
Is there anything better? Rust can handle this more gracefully using traits [2] but I can't find a Move language equivalent.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Discord user ID
robojosef
Describe your question in detail.
Here's esoteric regarding generic function specialization for any Move gurus out there.
I have a function that is mostly Coin type generic. Most of the function applies generically to any coin type, except for one small step in the middle of the function that depends on the concrete coin type. Any advice on how to implement this?
I've only found two options:
A. Add a type_info check [1] to disambiguate the type, which feels gross
B. Forget about about generic types and just have a full copy of the function for each coin type supported
Is there anything better? Rust can handle this more gracefully using traits [2] but I can't find a Move language equivalent.
[1] https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-stdlib/doc/type_info.md
[2] https://www.tangramvision.com/blog/c-rust-generics-and-specialization
What error, if any, are you getting?
No response
What have you tried or looked at? Or how can we reproduce the error?
No response
Which operating system are you using?
macOS
Which SDK or tool are you using? (if any)
Aptos CLI
Describe your environment or tooling in detail
No response
Beta Was this translation helpful? Give feedback.
All reactions