Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Compile-time filtering tuple or hlist by implemented trait?
This is probably still a bit of a long shot in Rust's developing type system, but is there a way to filter a tuple or hlist of references based on whether those types implement one or ideally multiple traits? I'm wondering if there's some unholy combination of frunk, hlists, facet, and/or feature(min_specialization) (or other relatively stable/safe nightly features) to do this.
Essentially a function where I feed in (&FooImplementsTraits, &BarDoesntImplement, &BazImplementsTraits)
and get out (&FooImplementsTraits, &BazImplementsTraits)
(or an HList equivalent). Is that possible in Rust's type system at this point?
I know there's this trick that uses the preference for inherent methods, but that wouldn't work at the generic level over tuples/hlists. For use case context, I'm trying to work on improvements to gecs to be less macro-dependent, but I'm stuck on being able to filter archetypes by what component types they hold.
4 posts - 2 participants
🏷️ rust_feed