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

Implement slicing syntax. #17318

Merged
merged 2 commits into from
Sep 20, 2014
Merged

Implement slicing syntax. #17318

merged 2 commits into from
Sep 20, 2014

Conversation

nrc
Copy link
Member

@nrc nrc commented Sep 16, 2014

expr[], expr[expr..], expr[..expr],expr[expr..expr]

Uses the Slice and SliceMut traits.

Allows ... as well as .. in range patterns.

r? @pcwalton (or anyone else)

closes #17177

unsafe {
assert!(COUNT == 8);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

New line needed

@pcwalton
Copy link
Contributor

Can you add a run-fail test or two to make sure that cleanups run if failure happens during evaluation of a slice argument (for example, that the temporary generated by the LHS of .. is dropped if the RHS fails)? This is frequently a source of bugs with new grammar productions.

@pcwalton
Copy link
Contributor

Otherwise looks good, will rereview with those changes. Awesome work 👍

@nrc
Copy link
Member Author

nrc commented Sep 17, 2014

@pcwalton re-r?

I wasn't exactly sure what cleanup tests to add - does the one I added do what you want? And are there more things we should test?

@ghost
Copy link

ghost commented Sep 18, 2014

@nick29581 I think @pcwalton meant foo[a..b()] where b() fails.

nrc added 2 commits September 19, 2014 11:15
`expr[]`, `expr[expr..]`, `expr[..expr]`,`expr[expr..expr]`

Uses the Slice and SliceMut traits.

Allows ... as well as .. in range patterns.
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Sep 19, 2014
@bors bors merged commit cf9c586 into rust-lang:master Sep 20, 2014
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.

Implement overloaded slice notation
5 participants