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

Add all_equal #196

Merged
merged 1 commit into from
Apr 14, 2017
Merged

Add all_equal #196

merged 1 commit into from
Apr 14, 2017

Conversation

phimuemue
Copy link
Member

This refers to #175. I think going with dedup is a convenient, simple solution.

src/lib.rs Outdated
/// let data : Option<usize> = None;
/// assert!(data.into_iter().all_equal());
/// ```
fn all_equal(self) -> bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it's not always easy to decide, but I think this method should use &mut self and no Self: Sized, just like all. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, the method should be sorted among the methods, not the adaptors, so it needs to be moved down. next_tuple is the first non-adaptor in the trait.

@phimuemue
Copy link
Member Author

phimuemue commented Apr 12, 2017

I think we could use &mut self, but when I reconsidered the problem I found another issue that I think is possibly even more important: Do you think it would be wise to return Option<Item> instead of bool so that the users have the possibility to get a value if all are considered equal (and None if they are not equal)?

@bluss
Copy link
Member

bluss commented Apr 13, 2017

That's a good extension. But we need to find a new name of it then!

Hehe, I think of a good feature as being a combination of a natural name and a wanted functionality. We need both for it to be used.

@phimuemue
Copy link
Member Author

I re-checked with cargo +nightly test on my machine and obtained test result: ok. 74 passed; 0 failed; 5 ignored; 0 measured as output.

I think the travis failure is related to rust-lang/rustup#1062.

@bluss
Copy link
Member

bluss commented Apr 14, 2017

Great, thank you!

@bluss bluss merged commit a3b6461 into rust-itertools:master Apr 14, 2017
@bluss bluss mentioned this pull request Apr 14, 2017
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

Successfully merging this pull request may close these issues.

2 participants