2 ms·
It won’t be dynamically dispatched in Rust unless it’s a trait object.
by steveklabnik 7y ago
It won’t be dynamically dispatched in Rust unless it’s a trait object.
- xscott 7y agoI think your point is to emphasize there is no additional cost to method syntax. I wasn't trying to imply there was, only that when you want dynamic dispatch, you can only get it from method syntax. Another interesting asymmetry, which I think shows a weird favoritism for method syntax is that Rust allows both of these: object_of_type_A.foo() object_of_type_B.foo() But not both of these: foo(object_of_type_A) foo(object_of_type_B) Ignoring dynamic/static dispatch for the moment, you can overload if you use method syntax, but not if you use function syntax. For me, I would prefer the latter, but I think I'm clearly in the minority.