Say I have generic method
pub foo<T>(t: T) { unimplemented!() }
Is there some way to distinguish in runtime between different instantiations of this method?
For you to understand why I need this, here is some context. Original problem is mocking generic methods. When I create mock for trait method, I create pair of methods: first one is stub method for struct implementing trait, second one is mock's method generating expectation.
For example, given trait:
trait A { fn foo(&this, v: u32); }
following methods are generated:
impl A for AMock {
fn foo(&this, v: u32) { ... }
}
and
impl AMock {
fn foo_call<M0: Matcher<u32>>(&this, v: M0) -> Expectation<()> { ... }
}
However, this is problematic for generic methods, as I have to distinguish instantiations.
Supposing separate code is generated for each type I would use method address to distinguish between them, but how can I find relation between corresponding foo
and foo_call
instantiations?