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

feat: Add method to drop duplicates in ArrayExtTrait #172

Closed
1 of 2 tasks
bal7hazar opened this issue Aug 31, 2023 · 2 comments
Closed
1 of 2 tasks

feat: Add method to drop duplicates in ArrayExtTrait #172

bal7hazar opened this issue Aug 31, 2023 · 2 comments
Labels
enhancement Enhancement of the code, not introducing new features.

Comments

@bal7hazar
Copy link
Contributor

bal7hazar commented Aug 31, 2023

Feature Request

Describe the Feature Request

Droping duplicates would be interesting for many cases, especially after using a concat.

Describe Preferred Solution

Loop over the array, pop_front elements one by one and use contains to identifiy if the element already exists in the shortest array (input or ouput) then add the element in the ouput array.

Describe Alternatives

To discuss if needed.

Related Code

No related code.

Additional Context

Some references discussed in telegram:

If the feature request is approved, would you be willing to submit a PR?

  • Yes
  • No
@bal7hazar bal7hazar added the enhancement Enhancement of the code, not introducing new features. label Aug 31, 2023
@akhercha akhercha mentioned this issue Sep 28, 2023
9 tasks
0xLucqs pushed a commit that referenced this issue Sep 29, 2023
## Pull Request type

- [ ] Bugfix
- [X] Feature
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no API changes)
- [ ] Build-related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

Issue number [#172
](#172)

## What is the new behavior?

- Added the `unique` methods for `SpanTraitExt` & `ArrayTraitExt`,
- Added the corresponding unit tests.

## Does this introduce a breaking change?

- [ ] Yes
- [X] No

## Other information

For this little snippet:
```rust
let shortest: Span<T> = if (self.len() <= 1) || (ret.len() <= self.len()) {
    ret.span()
} else {
    self
};
```

Without the `self.len() <= 1` member some of my tests were failing.
Tried multiple things but couldn't find any better even though I feel
like there's a more optimized solution... Curious to have your inputs! 🙏

---------

Co-authored-by: akhercha <[email protected]>
Co-authored-by: gaetbout <[email protected]>
@gaetbout
Copy link
Collaborator

@LucasLvy this can be closed I think

@gaetbout
Copy link
Collaborator

@LucasLvy This can be closed

@0xLucqs 0xLucqs closed this as completed Nov 20, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Enhancement of the code, not introducing new features.
Projects
None yet
Development

No branches or pull requests

3 participants