rust-lang / rust-lang/rustlings

[exersizes/conversions/as_ref_mut.rs] Why should I want to use AsRef / AsMut

Open
#1,350 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-exercises C-enhancement
Dominant language
Rust
Stars
64.2k
Forks
11.3k
Avg merge
5h 24m
Merged PRs (30d)
2

Description

As a first time rust learner, after the as_ref_mut.rs lesson, I was left curious why AsRef or AsMut are valuable tools. Typically I look for a hint to provide these answers, however the hint is pretty lacking here:

Feature Request: Please provide a more elaborate explanation as to why AsRef or AsMut are so valueable, and why I would need to use them. Additionally, perhaps provide more unit tests also showcasing why I would want to use these two impls/methods.

(Just finished rustlings and really appreciate the work everyone has done on it! 🎉 💯 )

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with exercises/conversions/as_ref_mut.rs and read the existing lesson hint and examples. Expand the explanation of why AsRef and AsMut are useful, add unit-test examples that demonstrate those use cases, and confirm the exercise still teaches the intended conversions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.