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

Broken comparison function in compute_suggestion #1

Closed
ghost opened this issue Jan 2, 2017 · 2 comments
Closed

Broken comparison function in compute_suggestion #1

ghost opened this issue Jan 2, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented Jan 2, 2017

This comparison function is broken.

According to it, these two statements are true at the same time:

  • (11, 0.0) < (14, 0.0)
  • (14, 0.0) < (11, 0.0)

The vector will be sorted in a totally unreliable order.
See this issue and the fix suggested by @bluss: rust-lang/rust#38685

@alopatindev
Copy link
Owner

Thank you for finding this! Fixed.

@ghost
Copy link
Author

ghost commented Jan 5, 2017

Glad this got fixed! Just a quick note - you can simplify compare_channels_load a bit... :)

fn compare_channels_load(a: &ChannelLoad, b: &ChannelLoad) -> cmp::Ordering {
    (&a.1, &a.0).partial_cmp(&(&b.1, &b.0)).unwrap()
}

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

1 participant