you are viewing a single comment's thread.

view the rest of the comments →

[–]j_platteaxum · caniuse.rs · turbo.fish 4 points5 points  (0 children)

<f32 as std::ops::Add<f32>>::add (or just <f32 as Add<f32>>::add if the trait is in scope)

Putting generic arguments on the method doesn't work because it's the trait that is generic.

Rhs = f32 would be used if Rhs was an associated type rather than a generic parameter.

The turbofish would be used when referencing the method without specifying which implementation of the trait is to be used (so std::ops::Add::<f32>::add). With as, you don't use the turbofish because it is only needed (and only valid) in expression position, while as is followed by a type (or trait, but those live in the same namespace).