I got some structs which impled Marker Trait, which got the same associated function test().
Is it possible to make a function accept uninstantiated struct as parameter?
So that I can call T::test() directly without instantiation.
like
// this works but bar should be instantiated struct instance.
fn Foo(bar: T) -> String
where T: Marker {
T::test()
}
trait Marker: Sized {
fn test() -> String;
}
Or any other way I can achieve similar result?
The original code already had a where clause that will do the same thing right?
I think this is a type inference problem. How does foo know what concrete type of T to monomorphize to? The parameter wal doing that in the original code.
I think this is a case for the turbo fish. Assuming you have some struct Bar that is Marker, then you would do something like this: foo::<Bar>(). Rustc can then figure out exactly what type it needs to monomorphize.