3 ms·
Yes, that is true. If you use a literal array, you get i32 for the element type. I believe this is because of the signature: pub fn from_fn<T, const N: usiz
by steveklabnik 4y ago
Yes, that is true. If you use a literal array, you get i32 for the element type.
I believe this is because of the signature:
pub fn from_fn<T, const N: usize, F>(cb: F) -> [T; N]
where
F: FnMut(usize) -> T,
While T is unconstrained, N is a usize, which is used in the closure, which we then re-use as the element.
- sophacles 4y agoOK this is just kinda funny - I was right, but only by accident. For some reason I thought that the literal defaulted to usize not i32. The fact that this path makes my assertion of usize correct is pretty cool though. Thanks for diving into it!