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

dev: Felt252DictTrait::get could return a @T rather than T for more polivalence #5668

Open
tdelabro opened this issue May 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@tdelabro
Copy link
Contributor

tdelabro commented May 28, 2024

Problem

Returning T requires adding a +Copy<T> constraint which forces the user to go call entry and finalize for non-copy types, which is a painful DevX.

Solution

Returning a snapshot of the value, rather than the value itself.
The caller has one more degree of liberty, he can decide to never desnap it if he has no reason to pay this price.

Related code

Rust Slice::get returns a reference to the value, not the value itself.
Same for HashMap::get

Will I create a PR?

Here is a draft PR that does exactly that: #5667
I wrote it to make sure there were no huge blockers down the road. It looks like it works perfectly.
Tell me if you wish to merge it.

@tdelabro tdelabro added the enhancement New feature or request label May 28, 2024
@tdelabro
Copy link
Contributor Author

tdelabro commented May 29, 2024

@orizi I closed the draft PR as you asked, but the issue stays relevant.

Because it is a breaking change, it can't be merged easily. How do you think we should proceed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant