Why do some std :: fmt :: Debug * methods use dynamic dispatch?

These methods use dynamic scheduling (receive the attribute object &Debugas a parameter):

These methods use static dispatch and are written in terms of the associated method entry:

Why does the first list of methods use dynamic dispatch instead of static dispatch? If static sending has been used, will their use be limited?

+4
source share
1 answer

Static dispatching uses monomorphization, which creates a separate copy of the code for each particular type.

, , . , .

, ( &Trait).


RFC 640, , , . , . , -:

, codegen

- Debug impls, Debug , .

+5

All Articles