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 better .is_empty() for slice and vec iterators #37943

Merged
merged 1 commit into from
Nov 24, 2016

Conversation

bluss
Copy link
Member

@bluss bluss commented Nov 22, 2016

These iterators can use a pointer comparison instead of computing the length.

@rust-highfive
Copy link
Collaborator

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@bluss
Copy link
Member Author

bluss commented Nov 22, 2016

The answer to “doesn't the compiler figure this out” is no, see playpen https://is.gd/o09MRd

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Nov 22, 2016

📌 Commit f6becc9 has been approved by alexcrichton

@frewsxcv
Copy link
Member

@bors r-

error: use of unstable library feature 'exact_size_is_empty' (see issue #35428)
   --> /checkout/src/libcollections/../libcollectionstest/slice.rs:641:40
    |
641 |             assert_eq!(xs[i..j].iter().is_empty(), xs[i..j].is_empty());
    |                                        ^^^^^^^^
    |
    = help: add #![feature(exact_size_is_empty)] to the crate attributes to enable

error: variable does not need to be mutable
   --> /checkout/src/libcollections/../libcollectionstest/slice.rs:638:9
    |
638 |     let mut xs = [1, 2, 5, 10, 11];
    |         ^^^^^^
    |
note: lint level defined here
   --> /checkout/src/libcollections/../libcollectionstest/lib.rs:11:9
    |
11  | #![deny(warnings)]
    |         ^^^^^^^^

error: aborting due to 2 previous errors

Build failed, waiting for other jobs to finish...
error: Could not compile `collections`.

@frewsxcv
Copy link
Member

@bors: r-

…rators

These iterators can use a pointer comparison instead of computing the length.
@bluss
Copy link
Member Author

bluss commented Nov 23, 2016

Thanks, I fixed the test by amending

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented Nov 23, 2016

📌 Commit 74cde12 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Nov 24, 2016

⌛ Testing commit 74cde12 with merge 217f57c...

bors added a commit that referenced this pull request Nov 24, 2016
Implement better .is_empty() for slice and vec iterators

These iterators can use a pointer comparison instead of computing the length.
@bors bors merged commit 74cde12 into rust-lang:master Nov 24, 2016
@bluss bluss deleted the exact-is-empty branch November 24, 2016 14:51
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.

6 participants