This compiles:
use arrayvec::{Array, ArrayVec};
#[ext(pub, name = IterExt)]
impl<T: Iterator<Item = U>, U> T {
fn collect_arr<const N: usize>(self) -> [U; N]
where
[U; N]: Array<Item = U>,
ArrayVec<[U; N]>: Debug,
{
self.collect::<ArrayVec<[U; N]>>().into_inner().expect("collect_arr")
}
}
(Using the extend and arrayvec crates.)
But using it with a constant doesn't compile:

Even though pub const CUE_POINT_COUNT: usize = 8; is in scope!
If I write .collect_arr::<8usize>() instead, it compiles.
Also, if I don't use the extension trait method but inline it (.collect::<ArrayVec<[_; CUE_POINT_COUNT]>>().into_inner().unwrap()) it works with the constant!
So for some reason rustc can't see that CUE_POINT_COUNT == 8 here.
This compiles:
(Using the
extendandarrayveccrates.)But using it with a constant doesn't compile:

Even though
pub const CUE_POINT_COUNT: usize = 8;is in scope!If I write
.collect_arr::<8usize>()instead, it compiles.Also, if I don't use the extension trait method but inline it (
.collect::<ArrayVec<[_; CUE_POINT_COUNT]>>().into_inner().unwrap()) it works with the constant!So for some reason rustc can't see that
CUE_POINT_COUNT == 8here.