Wildcard pattern in function parameters.
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- documentation
Research direction
Start with the linked wildcard patterns section and investigate the Reference's treatment of function argument passing, which the issue says is currently undocumented. Done means clarifying why a wildcard function parameter still consumes its argument and adding a focused documentation update or write-up.
Written by the indexing model from the issue text.
Description
I noticed that the section on wildcard patterns says that:
Unlike identifier patterns, it does not copy, move or borrow the value it matches.
However for a function parameter, any arguments that match the wildcard are still consumed by the function:
fn main() {
let s = String::from("Hello");
f(s);
// Won't compile since `s` was moved.
println!("{}", s);
}
fn f(_: String) {}
One explanation I had in my head was that function arguments are moved into the function's "stack frame" first, before being bound to parameters. So even though _ does not bind to s, s will still be moved into the function's scope and thus be "consumed".
However, I wasn't able to find any documentation of argument passing in the reference.
I'm willing to do any write-ups to update the documentation if someone can point me at the right direction.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 607
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-lang/reference
-
A-const-eval A-undefined-behavior
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
A-resolve
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
A-coercions
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
All issues in rust-lang/reference
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100