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

Add slice::ExactChunks and ::ExactChunksMut iterators #47126

Merged
merged 11 commits into from
Jan 15, 2018

Commits on Jan 13, 2018

  1. Add slice::ExactChunks and ::ExactChunksMut iterators

    These guarantee that always the requested slice size will be returned
    and any leftoever elements at the end will be ignored. It allows llvm to
    get rid of bounds checks in the code using the iterator.
    
    This is inspired by the same iterators provided by ndarray.
    
    See rust-lang#47115
    sdroege committed Jan 13, 2018
    Configuration menu
    Copy the full SHA
    51d546f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    83396fc View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    802ba9e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e51a89a View commit details
    Browse the repository at this point in the history
  5. Apply review comments from @bluss

    - Simplify nth() by making use of the fact that the slice is evenly
      divisible by the chunk size, and calling next() instead of
      duplicating it
    - Call next_back() in last(), they are equivalent
    - Implement ExactSizeIterator::is_empty()
    sdroege committed Jan 13, 2018
    Configuration menu
    Copy the full SHA
    aa0c08a View commit details
    Browse the repository at this point in the history
  6. Remove useless assertion

    sdroege committed Jan 13, 2018
    Configuration menu
    Copy the full SHA
    cea36f4 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    6bf1dfd View commit details
    Browse the repository at this point in the history
  8. Mention in the exact_chunks docs that this can often be optimized bet…

    …ter by the compiler
    
    And also link from the normal chunks iterator to the exact_chunks one.
    sdroege committed Jan 13, 2018
    Configuration menu
    Copy the full SHA
    8a82e8e View commit details
    Browse the repository at this point in the history
  9. Use assert_eq!() instead of assert!(a == b) in slice chunks_mut() uni…

    …t test
    
    This way more useful information is printed if the test ever fails.
    sdroege committed Jan 13, 2018
    Configuration menu
    Copy the full SHA
    baa81dc View commit details
    Browse the repository at this point in the history
  10. Test the whole chunks instead of just an element in the chunks/chunks…

    …_mut tests
    
    Easy enough to do and ensures that the whole chunk is as expected
    instead of just the element that was looked at before.
    sdroege committed Jan 13, 2018
    Configuration menu
    Copy the full SHA
    ed77483 View commit details
    Browse the repository at this point in the history
  11. Add unit tests for exact_chunks/exact_chunks_mut

    These are basically modified copies of the chunks/chunks_mut tests.
    sdroege committed Jan 13, 2018
    Configuration menu
    Copy the full SHA
    5f4fc82 View commit details
    Browse the repository at this point in the history