Impl Trait as type for const and static variables

⚓ Rust    📅 2025-07-21    👤 surdeus    👁️ 11      

surdeus

Warning

This post was published 58 days ago. The information described in this article may have changed.

Would it be possible for the rust compiler to support impl Trait as type for const and static variables?

My motivation for this feature request is that I am encoding a lot of information in the generics of a struct and it would be really unruly for the user to manually enter the full type.

The user could end up having to write something like Data<Var<Var<Var<usize>>>, (Scope<Var<usize>>, Scope<Var<usize>)>. If they end up modifying the generating code they would have to edit the type as well.

Is there a way I can preserve the type information while also not force the user to write and maintain a huge type on a const/static?

2 posts - 2 participants

Read full topic

🏷️ rust_feed