Type Aliases

Basic aliases

tape
type Byte = u8;
type Callback = fn(i64) -> void;
type Buffer = []u8;

Why use aliases

  • Shorten long types used repeatedly
  • Give domain-specific names to generic types
  • Create function pointer types for event signatures

Example

tape
type EventHandler = fn(*u8, i64) -> void;
type Slice = []const u8;
type Result = i64 or ParseErr;

Type aliases are fully transparent — the compiler treats the alias and the original type as identical.

Type aliases cannot be pub — they are module-private.

Last modified: