Rust Unsafe Keyword

Cluster focuses on debates about Rust's `unsafe` keyword, including its meaning, whether it compromises overall safety, its role in building safe abstractions, and necessity for low-level code.

➡️ Stable 0.7x Programming Languages
4,319
Comments
19
Years Active
5
Top Authors
#6028
Topic ID

Activity Over Time

2008
3
2009
4
2010
10
2011
21
2012
26
2013
65
2014
147
2015
210
2016
271
2017
320
2018
243
2019
256
2020
401
2021
364
2022
422
2023
467
2024
477
2025
560
2026
58

Keywords

ANYONE e.g CPU GC IMO github.com API IO unsafe safe code constructor rust language safety languages stdlib memory

Sample Comments

steveklabnik • Aug 3, 2020 • View on HN

It's not possible, because unsafe does not turn anything off; unsafe is a superset of safe.

IshKebab • Dec 16, 2023 • View on HN

Not really. `unsafe` is the footgun.

OutOfHere • Jun 13, 2024 • View on HN

Why not though (for safety-critical code)? How can it be safe with `unsafe`?

kouteiheika • May 22, 2023 • View on HN

`unsafe` doesn't mean that it's not safe, just that the compiler can't prove that it's safe so the human has to do it manually.

tptacek • Nov 24, 2025 • View on HN

It's got really not much at all to do with `unsafe`.

briansm • May 21, 2025 • View on HN

and yet an article about a 'safe' language has code examples full of 'unsafe'... wut.

kinghajj • Feb 23, 2018 • View on HN

No on both counts, the entire point of "unsafe" is to form safe abstractions around unprovably safe code.

doliveira • Jul 19, 2020 • View on HN

What's the problem with unsafe? Isn't the whole point to isolate the unsafe behavior into specific parts of the code?

jdub • Jul 19, 2020 • View on HN

There's necessary and well-encapsulated `unsafe` code in the standard library. It's a tool.

Animats • Nov 28, 2016 • View on HN

No. As soon as there's unsafe code, there's the possibility of safe code misusing the unsafe code to create unsafe behavior. One would like to have un-abusable unsafe code, but the language does nothing to guarantee that.