3 ms·
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
by crznp 3y 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);
- _nalply 3y agoOr declare the type of bool_arr.
- kibwen 3y ago> seems like spooky action at a distance 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.