Term for "exact type turned into a dyn"?

As @quinedot pointed out in your other thread

So the differences are:

Some kinds of unsizing coercions may not be considered type erasure. Coercing to a slice from an array like Box<[T; N]> to Box<[T]> might not be called “type erasure”. Sure, it erases the array length, but dynamic length information is so common that it doesn’t necessarily count as an erased type. (After all, Box<[T]> can also be very well thought of as just an alternative to Vec<T> without the option for spare capacity.)

Some kinds of type erasure are not related to unsizing coercions. (The mentioned example of “passing around *mut () with some other way of tracking the type at runtime”.)

The terminologies differ in their grade of formality.

I, too, understand “type erasure” as an informal term for some programming concept; the concept that the implementation of type objects is based on, the concept to bundle up some somewhat untyped data, often with some pointer type (often something like *const () or *mut ()), sometimes also with data (like some [MaybeUninit<u8>; N] array… or even a union[1]) that could be pointing to values of different types, together with additional information that makes it stillusable. By the way, check out the first part of this video for a great exposure to the ideas how trait objects are / could be implemented manually:

On the other hand, “unsizing coercions” are clearly defined. They are those (implicit) type coercions in Rust that are powered by the CoerceUnsized trait internally.


  1. combing a union with a tag ==>> maybe enums are an instance of “type erasure”, too… right? ↩︎

4 Likes