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

Confusion about as_ref_mut #2199

Open
Ekryd opened this issue Jan 19, 2025 · 0 comments
Open

Confusion about as_ref_mut #2199

Ekryd opened this issue Jan 19, 2025 · 0 comments

Comments

@Ekryd
Copy link

Ekryd commented Jan 19, 2025

Hi!

Thank you for your excellent work on the Rustlings exercises. Most of the tasks were easy to follow and had a clear purpose. However, I found myself completely stumped by the as_ref_mut exercise, as I had no idea what I was supposed to do or why I would use this language construct at all.

Initially, I thought the goal was to write my own AsRef implementation for some sort of generic type or even for str itself. Neither reading the documentation nor searching for additional information helped to clarify this. In the end, I had to resort to looking at the solution files to figure out what to do. 😞

I humbly suggest the following improvements for the as_ref_mut exercise:

  • Provide a bit more background on why AsRef is needed and how it is commonly used.
  • Use more practical example where AsRef really adds significant value.
  • Let the user implement their own AsRef implementation for a type as a learning exercise.
  • Consider removing the generics, as it was a bit distracting (at least for me).

Thank you again for your hard work on this project!

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

No branches or pull requests

1 participant