Skip to content

Document vector destructuring with wildcard '..' #11877

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

Merged
merged 1 commit into from
Jan 29, 2014

Conversation

Armavica
Copy link
Contributor

This feature already was in the tutorial, but I believe that the tutorial should be a strict subset of the manual.

I also added an example.

Used inside a vector pattern, `..` stands for any number of elements (This
wildcard can be used at most once for a given vector, which implies that you
cannot use it to specifically match elements that are at an unknown distance
from both ends of a vector, like `[.., 42, ..]`.). Followed by a variable name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence should probably just be a sentence without parens around it. Additionally, can you mention that it's possible to not provide a name and thus just ignore a bunch of elements? It sounds like the last sentence means that you need to provide a name to bind the elements.

@Armavica
Copy link
Contributor Author

@alexcrichton thank you for your comments. In fact I am not sure of the relevance of the sentence that says that .. cannot be used twice in a single vector, but that may be a question that users ask themselves and the error message for this is not particularly enlightening (error: unexpected token: '..'). Maybe could it be improved?

@alexcrichton
Copy link
Member

I think what you have certainly works for now in terms of documentation, we can revisit the error message later if necessary.

bors added a commit that referenced this pull request Jan 29, 2014
This feature already was in the tutorial, but I believe that the tutorial should be a strict subset of the manual.

I also added an example.
@bors bors closed this Jan 29, 2014
@bors bors merged commit d62097d into rust-lang:master Jan 29, 2014
@Armavica Armavica deleted the doc-pm-vector branch January 29, 2014 21:26
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 1, 2023
`TypeckResults::node_type()` can be used inside of bodies

Doc fix.

changelog: none
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

Successfully merging this pull request may close these issues.

3 participants