-
Notifications
You must be signed in to change notification settings - Fork 123
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
Fix IntoIterator derived bounds (#208) #284
Fix IntoIterator derived bounds (#208) #284
Conversation
6b7b11d
to
b8cef6f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are still failing.
iter: I, | ||
vals: &[T], | ||
) { | ||
assert_eq!(iter.into_iter().collect::<Vec<_>>(), vals); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MegaBluejay such unification is not good for tests, as doesn't allow us to understand well which assertion in the test case is failing exactly:
---- generic stdout ----
thread 'generic' panicked at 'assertion failed: `(left == right)`
left: `[1, 2, 3]`,
right: `[]`', tests/into_iterator.rs:18:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- generic_bounds stdout ----
thread 'generic_bounds' panicked at 'assertion failed: `(left == right)`
left: `[1, 2, 3]`,
right: `[]`', tests/into_iterator.rs:18:5
---- generic_refs stdout ----
thread 'generic_refs' panicked at 'assertion failed: `(left == right)`
left: `[1, 2, 3]`,
right: `[]`', tests/into_iterator.rs:18:5
---- generic_owned stdout ----
thread 'generic_owned' panicked at 'assertion failed: `(left == right)`
left: `[1, 2, 3]`,
right: `[]`', tests/into_iterator.rs:18:5
---- named_single stdout ----
thread 'named_single' panicked at 'assertion failed: `(left == right)`
left: `[1, 2, 3]`,
right: `[]`', tests/into_iterator.rs:18:5
---- tuple_single stdout ----
thread 'tuple_single' panicked at 'assertion failed: `(left == right)`
left: `[1, 2, 3]`,
right: `[]`', tests/into_iterator.rs:18:5
#[track_caller]
may be helpful here to some degree, but not when multiple assertions are united in the same helper function.
Resolves #208
Synopsis
For generic structs, some derived IntoIterator bounds are based on the struct's type parameters, rather than the field used in the implementation.
Solution
Require only the type of the field used to be
IntoIterator
Checklist
Note
I don't think this is a breaking change, since no program where the newly added bounds aren't satisfied would have compiled.