---
source: https://iinventedlight.com/library/notes/rust-unsafe-basics.md
title: "Unsafe Rust basics"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (rust-lang/book; Copyright (c) 2010 The Rust Project Developers); additional cited sources under MIT OR Apache-2.0; prose restates cited source lines in own words"
license_family: rust-mit
attribution: "Summary by iinventedlight (AI-assisted). Sources: The Rust Project (The Rust Programming Language book), Unsafe Rust, MIT OR Apache-2.0; Rust by Example (rust-lang/rust-by-example), Unsafe operations - Rust By Example, MIT OR Apache-2.0. Notices: The Rust Programming Language book (rust-lang/book): Copyright (c) 2010 The Rust Project Developers; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/book/blob/main/LICENSE-MIT). Rust by Example (rust-lang/rust-by-example): Copyright (c) 2014 Jorge Aparicio; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/rust-by-example/blob/master/LICENSE-MIT)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-09
status: published
approved_by: "Cole Withington, 2026-11-09 13:40 PT: \"Yes, publish all 15 Rust drafts\""
checked_on: 2026-11-09
as_of: 2026-11-09
confidence: medium
untested: "No Rust code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-systems: Rust unsafe"
tags: [rust, unsafe, raw-pointers, ffi]
client: Librarian
sources:
  - id: S1
    title: "Unsafe Rust"
    publisher: The Rust Project (The Rust Programming Language book)
    url: https://doc.rust-lang.org/book/ch20-01-unsafe-rust.html
    accessed: 2026-11-09
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "Unsafe operations - Rust By Example"
    publisher: Rust by Example (rust-lang/rust-by-example)
    url: https://doc.rust-lang.org/rust-by-example/unsafe.html
    accessed: 2026-11-09
    license: "MIT OR Apache-2.0"
---
# Unsafe Rust basics

**Answer:** Unsafe Rust adds five "superpowers" that safe Rust forbids. You may build raw pointers in safe code, but you may only dereference them inside `unsafe`.

## Unsafe blocks

Unsafe annotations bypass compiler protections on purpose. Enter unsafe Rust with the `unsafe` keyword and a block that contains the unsafe operations.

## Claims

- id: C1
  claim: Raw pointers can be created in safe code but not dereferenced there.
  source: S1
  evidence: "We can create raw pointers in safe code; we just can't dereference raw pointers outside"
- id: C2
  claim: You can take five actions in unsafe Rust that you can't in safe Rust.
  source: S1
  evidence: "You can take five actions in unsafe Rust that you can't in safe Rust, which"
- id: C3
  claim: Unsafe annotations bypass compiler protections.
  source: S2
  evidence: "Unsafe annotations in Rust are used to bypass protections put in place by the compiler;"

## Sources

- [S1] Unsafe Rust. The Rust Project (The Rust Programming Language book). https://doc.rust-lang.org/book/ch20-01-unsafe-rust.html . License: MIT OR Apache-2.0. Accessed 2026-11-09.
- [S2] Unsafe operations - Rust By Example. Rust by Example (rust-lang/rust-by-example). https://doc.rust-lang.org/rust-by-example/unsafe.html . License: MIT OR Apache-2.0. Accessed 2026-11-09.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources and notices: The Rust Programming Language book (rust-lang/book): Copyright (c) 2010 The Rust Project Developers; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/book/blob/main/LICENSE-MIT). Rust by Example (rust-lang/rust-by-example): Copyright (c) 2014 Jorge Aparicio; MIT OR Apache-2.0, used under MIT (https://github.com/rust-lang/rust-by-example/blob/master/LICENSE-MIT). Text was condensed and changed from the originals.

---

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