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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Itertools::tail #899

Merged

Commits on Mar 17, 2024

  1. New Itertools::tail

    The `.tail(1)` test is for code coverage.
    Philippe-Cholet committed Mar 17, 2024
    Configuration menu
    Copy the full SHA
    77f8db3 View commit details
    Browse the repository at this point in the history
  2. Itertools::tail: skip the starting part of the iterator

    If the iterator is exact sized, then `.collect()` finishes the work.
    More generally, if the size hint knows enough and `nth` is efficient, this might skip most of the iterator efficiently.
    
    In the tests, `.filter(..)` is there to ensure that `tail` can't leverage a precise `size_hint` to entirely skip the iteration after initial `.collect()`.
    
    Co-Authored-By: scottmcm <scottmcm@users.noreply.github.com>
    Philippe-Cholet and scottmcm committed Mar 17, 2024
    Configuration menu
    Copy the full SHA
    0578354 View commit details
    Browse the repository at this point in the history
  3. Itertools::tail: return VecDeque rather than Vec

    `rotate_left` is more efficient on `VecDeque` than on a slice.
    `VecDeque::from(vec)` is O(1) on recent rust.
    
    Co-Authored-By: scottmcm <scottmcm@users.noreply.github.com>
    Philippe-Cholet and scottmcm committed Mar 17, 2024
    Configuration menu
    Copy the full SHA
    3373c7a View commit details
    Browse the repository at this point in the history
  4. Check two invariants

    Philippe-Cholet committed Mar 17, 2024
    Configuration menu
    Copy the full SHA
    b51f26a View commit details
    Browse the repository at this point in the history