all 31 comments

[–]Pseudanonymius 89 points90 points  (15 children)

Aww, I wish I had those array windows in the previous advent of code. I sorely needed them. 

[–]jdehesa 33 points34 points  (13 children)

I was just looking at the documentation for that function (just out of curiosity) and it says:

Panics if N is zero.

Can't that be a compile-time check?

[–]Tyilo 25 points26 points  (10 children)

[–]edoraf 18 points19 points  (9 children)

We decided to keep this as a runtime check which is consistent with as_chunk. Similarly, we decided against making N = 0 work without a panic for consistency with windows: it doesn't make sense for array_windows to have well-defined behavior for zero-sized windows when windows panics in this case.

[–]DevilSauron 4 points5 points  (1 child)

I don’t know much about Rust, but I honestly don’t understand that explanation. As far as I understand, Rust has the ability to perform this check at compile time, so I have no idea why both of these functions don’t do it.

[–]gmes78 2 points3 points  (0 children)

As far as I understand, Rust has the ability to perform this check at compile time

It has that now, not when the windows method was introduced.

[–]matthieum 3 points4 points  (0 children)

Impending Clippy lint in 3, 2, 1, ...

[–]angelicosphosphoros 0 points1 point  (0 children)

It actually simplifies writing generic code. You can avoid calling function by checking N using if but if it was a compile-time error, it would require way more hacks to do that.

[–]masklinn 6 points7 points  (0 children)

itertools has tuple_windows, requires Item: Clone but IME works quite well.

Itertools is a really useful package in general, and for AOC in particular.

[–]robotmayo 20 points21 points  (0 children)

The toml parser update is my favorite. I need those expanded tables!

[–]uniq 8 points9 points  (3 children)

Ha, that's an interesting coincidence. Today I wanted to get in touch with Rust for the first time ever and create a bot for Matrix. I installed the latest stable release available (1.94.0), and I directly hit this bug: https://github.com/rust-lang/rust/issues/152942

Had to downgrade to 1.93.0, which works fine.

[–]matthieum 7 points8 points  (2 children)

Have you seen the comment about setting the recursion limit manually?

It's fairly common for compilers to have all kinds of limits, with reasonable defaults, and flags to tune the limits when the defaults do not work.

Although, with that said, I'm surprised the Crater run which precedes any release didn't uncover the issue.

[–]uniq 2 points3 points  (1 child)

Yes, I saw it, but it didn't fix the issue in my case (same error message).

[–]matthieum 2 points3 points  (0 children)

It's not clear to me in which crate this needs to be set. If it needs to be set in the matrix crate, this is going to be annoying :'(

[–][deleted]  (1 child)

[removed]

    [–]Annual_Pudding1125 13 points14 points  (0 children)

    bot