do rust traits have runtime overhead?

If the concrete type is known statically, then static dispatch is used.

If the concrete type is not known (i.e. a trait object: &dyn ExampleTrait), then dynamic dispatch is used.

See also:

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top