I am a little confused on this syntax. Can someone help me really fast?

I am doing the wasm-game-of-life tutorial and just the syntax below is confusing me a little bit.

for delta_col in [self.width - 1, 0, 1].iter().cloned()

I understand everything in line expect for the [self.width - 1, 0, 1]. I tried looking it up online but was unsure what to even google to find the information on the other two numbers in that line.

I get everything expect the additional "0, 1". Any help would be greatly appreciated!

Thank you!

That's syntax for an array of length 3, with the elements self.width - 1, 0 and 1.

As an aside, it's quite likely that the .cloned() call can be removed since the elements implement Copy (they are all built-in integer types. But which one exactly depends on either the type of self.width or usage context).

That's just an array of 3 elements. You're probably overthinking.

That loop doesn't need .iter().cloned():

for delta_col in [self.width - 1, 0, 1] {

The tutorial in question probably predates the rust (1.53?) version in which array implements IntoIterator

Side note @BubbaBlount take the date of the tutorial into account and be sure to also check the Rust Book, reference and documentation (and in the general the "learn" page).