Can't use type parameters from outer function

What is the proper way to do a method in an impl block with a const generic bound, where the method parameter uses const generic and a locally defined const in the method also uses that const generic?

Full post here.

Not a solution to your question per se, but one workaround is to move const C up a level to be an associated constant of the struct.

Thanks for the reply! Do not think this works, can see discussion for why here

Associated consts on structs do work. It's associated consts on traits when in a generic impl that don't work. (I think I could have explained that better in the linked thread)

So replying in the other thread, but, this is why was worrying about creating two separate threads. The issue is a bit separate. This is referring to const dependent on a const generic inside a fn that is part of a trait implementation, not associated const. Adding field to struct is also non-constant does not work. Expanding @quinedot also can not use type parameters from outer function . This is as you say where associated consts on structs do not work and only works if no trait. Updated original post to make this more clear trait is part of question. There is trait where const in fn uses const generic, but not associated const.

Alright, I'll keep my answers in the other thread :slight_smile:

1 Like