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

LinearGroupByKey could allow provided closure to borrow from input #25

Open
Ten0 opened this issue Aug 16, 2023 · 1 comment
Open

LinearGroupByKey could allow provided closure to borrow from input #25

Ten0 opened this issue Aug 16, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Ten0
Copy link

Ten0 commented Aug 16, 2023

Current:

fn linear_group_by_key<F, K>(&self, func: F) -> LinearGroupByKey<T, F>
    where F: FnMut(&T) -> K,
          K: PartialEq

Does not allow:

let strings = vec!["A".to_owned()];
strings.linear_group_by_key(|s| s.as_str());

In order for that to work, we need:

fn linear_group_by_key<'a, F, K>(&'a self, func: F) -> LinearGroupByKey<T, F>
    where F: FnMut(&'a T) -> K,
          K: PartialEq

Since nothing moves in memory it should be possible.

@Kerollmops
Copy link
Owner

Hey @Ten0 👋

That's a great idea, and it is not breaking. Can you please propose a pull request and even copy/paste your comment into this official thread, too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants