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

Implemented drain_filter for HashMap #135

Merged
merged 4 commits into from
Dec 24, 2019
Merged

Commits on Dec 21, 2019

  1. Implemented drain_filter

    Drain filter is as described in the doc comments.
    
    The implementation is based almost entirely on retain's implementation, as per `amanieu`'s
    suggestion.
    I messed around with the lifetimes, as I'm not entirely familiar with the unsafe `iter`
    on the raw table, but since we're now using a lazy iterator, the predicate must be valid for as
    long as the borrow on the table.
    
    I also annotated the function with a `#[must_use]`, otherwise the drain would have no effect.
    
    Please let me know if there are any other additions before this change can be added.
    Thanks!
    JulianKnodt committed Dec 21, 2019
    Configuration menu
    Copy the full SHA
    e0c7f13 View commit details
    Browse the repository at this point in the history
  2. Updated to fix clippy

    Fixed clippy lint (added tab and spaced out `=(K,V)` => `= (K, V)`).
    
    Also made the test more explicit.
    
    Edit:
    I've finally installed clippy rather than checking Travis.
    JulianKnodt committed Dec 21, 2019
    Configuration menu
    Copy the full SHA
    4dd50ab View commit details
    Browse the repository at this point in the history
  3. Updated with DrainFilter struct

    The previous implementation did not match vec's drain filter's drop semantics. As per
    `amanieu`'s suggestion, added a DrainFilter which implements drop so that it removes the
    items which don't satisfy the predicate.
    JulianKnodt committed Dec 21, 2019
    Configuration menu
    Copy the full SHA
    1d5fac2 View commit details
    Browse the repository at this point in the history
  4. Added drop guard

    JulianKnodt committed Dec 21, 2019
    Configuration menu
    Copy the full SHA
    0a65d86 View commit details
    Browse the repository at this point in the history