Right now, if a trait as associated items, reflection is difficult to impossible. My personal case is trying to reflect on an async function. I quickly run into the problem of being unable to determine if a function returns a Future because I have no way of binding Future::Output.
A possible solution that @oli-obk and I brainstormed would be a trait_of! macro, which would take the implementer, plus the trait as an ident, and return a Trait. Further, extensions similar to the below would need to be added around Trait.
pub struct Trait {
// ...
pub associated: &'static [TraitAssocProperty];
}
pub struct TraitAssocProperty {
pub name: &'static str;
pub kind: TraitAssocPropertyKind;
pub ty: TypeId,
}
pub enum TraitAssocPropertyKind {
Constant,
Type
}
Related to: #146922 and #144361
Right now, if a trait as associated items, reflection is difficult to impossible. My personal case is trying to reflect on an async function. I quickly run into the problem of being unable to determine if a function returns a
Futurebecause I have no way of bindingFuture::Output.A possible solution that @oli-obk and I brainstormed would be a
trait_of!macro, which would take the implementer, plus the trait as an ident, and return aTrait. Further, extensions similar to the below would need to be added aroundTrait.Related to: #146922 and #144361