---
source: https://iinventedlight.com/library/notes/rust-advanced-types.md
title: "Rust advanced types: newtypes, type aliases, and the never type"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (The Rust Project Developers); MIT OR Apache-2.0 (The Rust Project Developers); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: The Rust Project Developers, Advanced Types - The Rust Programming Language; The Rust Project Developers, Advanced Types (source). MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: rust-advanced-types"
tags: [rust, newtype, type-alias, never-type, types]
client: Librarian
sources:
  - id: S1
    title: "Advanced Types - The Rust Programming Language"
    publisher: The Rust Project Developers
    url: https://doc.rust-lang.org/book/ch20-03-advanced-types.html
    accessed: 2026-11-26
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "Advanced Types (source)"
    publisher: The Rust Project Developers
    url: https://raw.githubusercontent.com/rust-lang/book/main/src/ch20-03-advanced-types.md
    accessed: 2026-11-26
    license: "MIT OR Apache-2.0"
---
# Rust advanced types: newtypes, type aliases, and the never type
**Answer:** The Rust type system has some features mentioned earlier but not yet discussed: newtypes, type aliases, the ! type, and dynamically sized types.

## Newtypes and type aliases

The discussion starts with newtypes and why they are useful as types, then turns to type aliases, which are similar but have slightly different semantics.

Beyond earlier examples, the newtype pattern can statically keep values from being mixed up and can mark the units of a value.

Listing 20-16 wrapped u32 values in Millimeters and Meters for that reason.

The pattern is a lightweight way to hide implementation details, as discussed with encapsulation in Chapter 18.

A type alias, declared with the type keyword, gives an existing type another name.

Aliases do not add the type-checking benefits of a newtype: mixing Kilometers and i32 will not produce a compiler error.

The main use case for type synonyms is to reduce repetition. Type aliases are also commonly used with the Result<T, E> type for reducing repetition.

## The never type

Rust also has a special type named !.

In type theory this is the empty type, because it has no values.

The book prefers the name never type, because it is used as the return type of a function that will never return.

The chapter also discusses dynamically sized types after this section.

## See also

- [rust-associated-types](https://iinventedlight.com/library/notes/rust-associated-types/)
- [rust-traits](https://iinventedlight.com/library/notes/rust-traits/)
- [rust-unsafe-basics](https://iinventedlight.com/library/notes/rust-unsafe-basics/)

## Claims

- id: C1
  claim: Type aliases do not catch mixed units the way a newtype does.
  source: S1
  evidence: "we don't get the type-checking benefits that we get from the newtype pattern"

- id: C2
  claim: The usual reason to write a type synonym is to avoid repetition.
  source: S2
  evidence: "The main use case for type synonyms is to reduce repetition."

- id: C3
  claim: The ! type is used when a function never returns.
  source: S1
  evidence: "We prefer to call it the never type"

## Sources

- [S1] Advanced Types - The Rust Programming Language. The Rust Project Developers. https://doc.rust-lang.org/book/ch20-03-advanced-types.html . License: MIT OR Apache-2.0. Accessed 2026-11-26.

- [S2] Advanced Types (source). The Rust Project Developers. https://raw.githubusercontent.com/rust-lang/book/main/src/ch20-03-advanced-types.md . License: MIT OR Apache-2.0. Accessed 2026-11-26.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Rust Project Developers, Advanced Types - The Rust Programming Language; The Rust Project Developers, Advanced Types (source). MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
