|
|
|
|
|
by crznp
834 days ago
|
|
That's interesting, though the type inference seems like spooky action at a distance there: removing an assertion can break code. I suppose it gives you a way to specify the length in the examples (below), but it seems more ergonomic to take it from the original array. let bool_arr = core::array::from_fn::<_, 5, _>(|i| i % 2 == 0);
|
|
Note that this inference is static, and the compiler would tell you if it didn't have something concrete to infer the type from. The type inference is also limited to the function body, so removing the assertion could only ever cause an effect in that single function.