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

Support custom comparison with capture_diff_slices_by #27

Open
WiSaGaN opened this issue Jun 21, 2021 · 3 comments
Open

Support custom comparison with capture_diff_slices_by #27

WiSaGaN opened this issue Jun 21, 2021 · 3 comments

Comments

@WiSaGaN
Copy link

WiSaGaN commented Jun 21, 2021

I should first say, thank you for the crate, this is very useful for even comparing binary data.

Similar to capture_diff_slices but user can supply a F: FnMut(&T, &T) -> Ordering.
This is more of a wishlist since I don't have a concrete design in mind. Please feel free to close if this is not possible or not on the roadmap.

@mitsuhiko
Copy link
Owner

Do you have a specific usecase in mind for this?

@WiSaGaN
Copy link
Author

WiSaGaN commented Aug 17, 2021

I am currently using this to align two data series from different sources while they both describes the same underlying event stream, e1....en, which we don't have other ways to observe:

  • Each data series are measurements of this event stream
  • Data series may have missing data regarding to some events, the missing data may be different for different data series

So I now use capture_diff_slices with success to form a combined and sorted data series. However, this is based on the assumption that the data points from different series are equal if they describe the same event. This is not the case for some kind of data. Data points from different data sources may have fields that have different values due to observation defects, which we know beforehand, and thus would like to ignore when we do the capture_diff_slices. In rust, I want to have a way to supply the compare function so that I can change it dynamically instead of implementing new Ord/Eq.

@Dushistov
Copy link

Dushistov commented Apr 25, 2022

I need this feature too. I compare two slices with Foo defined like this:

struct Foo {
   uuid: Uuid,
   others: Data,
}

In particular algorithm I compare slices only by uuid field,
but in other algorithms I need PartialEq that take others also into account.
So I have to create two Vec<Wrapper<'a>>, where Wrapper hold
reference to Foo and its PartialEq compare only uuid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants