Skip to content

Commit

Permalink
More correctly state what happens when iterating over Rust array types
Browse files Browse the repository at this point in the history
As of Rust 1.48, array types do not actually implement IntoIterator, which
means that the borrow checker automatically introduces borrows with
surprising results. This behavior is now explicitly marked as unstable:

warning: this method call currently resolves to
`<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but
that might change in the future when `IntoIterator` impls for arrays
are added.
warning: this was previously accepted by the compiler but is being
phased out; it will become a hard error in a future release!
note: for more information, see issue #66145
<rust-lang/rust#66145>

This commit changes the into_iter() calls into iter() calls that
match the current behavior in Rust.
  • Loading branch information
michaelcmartin committed Dec 22, 2020
1 parent cf15096 commit 6952431
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/save/puzzles/noreturn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl Tomlable for NoReturnState {
let value = cmp::min(value, order.len() - 1);
order[index] = value;
}
for (index, value) in order.clone().into_iter().enumerate() {
for (index, value) in order.clone().iter().enumerate() {
if order[..index].contains(value) {
order = INITIAL_ORDER;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/save/puzzles/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl Tomlable for OrderState {
let value = cmp::min(cmp::max(0, value) as usize, order.len() - 1);
order[index] = value;
}
for (index, value) in order.clone().into_iter().enumerate() {
for (index, value) in order.clone().iter().enumerate() {
if order[..index].contains(value) {
order = *INITIAL_ORDER;
break;
Expand Down

0 comments on commit 6952431

Please sign in to comment.