Type Aliases and Newtype
C uses typedef heavily:
typedef uint32_t DeviceId;
typedef uint8_t Byte;
typedef int (*compare_fn)(const void *a, const void *b);
It reduces repetition, hides complex declarations, and gives a business name to a type. But typedef does not always create a stronger type boundary. Often it is just another name for the original type.
Rust has two common tools:
type DeviceId = u32; // type alias, not a new type
struct DeviceId(u32); // newtype, a distinct type
The important split is simple: use an alias to simplify names; use a newtype when you want the compiler to stop accidental mixing.
Read More