phip1611
phip1611

Reputation: 6170

Rust syntax: assignment to underscore without let

For a few Rust versions now, one can do _ = foo() instead of let _ = foo() in assignments. However, I can not recall the name of this syntax and can't find official documentation for it. I also don't find the PR in the rustlang repo. Can anyone provide some context, please?

Upvotes: 5

Views: 270

Answers (1)

Chayim Friedman
Chayim Friedman

Reputation: 71380

It is part of the destructuring assignment RFC, that allows pattern to be used for assignments and not just variable declaration. Stabilized in Rust 1.59.0.

Upvotes: 5

Related Questions