Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make methods accepting ids by value generic over its referencedness #4832

Open
DCNick3 opened this issue Jul 10, 2024 · 0 comments
Open

Make methods accepting ids by value generic over its referencedness #4832

DCNick3 opened this issue Jul 10, 2024 · 0 comments
Labels
api-changes Changes in the API for client libraries Enhancement New feature or request

Comments

@DCNick3
Copy link
Contributor

DCNick3 commented Jul 10, 2024

In a lot of places we accept an id (like AccountId) by value, requiring spelling out .clone() in a lot of places where the id cannot actually be consumed.

A very similar problem is faced when passing strings in rust. Into<String> is a generally acceptable way to receive an owned string value, while allowing implicit clones of &String and &str.

I think we can get a similar benefits by implementing From<&Id> for Id for all out id types and using Into<Id> in function signatures. Then instead of whiff(floof.clone()) we would be able to write whiff(&floof).

I feel the client-facing APIs (like constructing instructions and queries) could benefit greatly from this: our integration tests have a lot of clutter in form of .clone()s. Some parts of iroha_core might benefit too.

@DCNick3 DCNick3 added Enhancement New feature or request api-changes Changes in the API for client libraries labels Jul 10, 2024
@DCNick3 DCNick3 mentioned this issue Jul 10, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-changes Changes in the API for client libraries Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants