dspyz
dspyz

Reputation: 5510

Rust type hint with method call syntax

Is there a way to provide a type hint for a trait method without moving the receiver into the argument list?

For instance, if I have some x and call

x.foo(y)

and I need to clarify that foo is a method of the trait T, do I have to write it as:

<_ as T>::foo(x, y)

or is there some syntax that looks more like

x::<as T>.foo(y)

that I can use?

Upvotes: 2

Views: 607

Answers (1)

Steven P
Steven P

Reputation: 1996

You just have to make sure that the trait T is in scope with a use statement...

Upvotes: 1

Related Questions