How to make a const parameter generic?

⚓ Rust    📅 2026-02-19    👤 surdeus    👁️ 1      

surdeus

I have this code

struct Min<T, const N: usize>(T, PhantomData<usize>);

But N isn't always a usize. I tried passing N: T to make N could accept any numeric type like this, but it didn't work

struct Min<T, const N: T>(T, PhantomData<T>);

Is there a way to do this?

3 posts - 3 participants

Read full topic

🏷️ Rust_feed