rust-unsafe
Installation
SKILL.md
When Unsafe is Justified
| Use Case | Example | Justified? |
|---|---|---|
| FFI calls to C | extern "C" { fn libc_malloc(size: usize) -> *mut c_void; } |
✅ Yes |
| Low-level abstractions | Internal implementation of Vec, Arc |
✅ Yes |
| Performance optimization (measured) | Hot path with proven bottleneck | ⚠️ Verify first |
| Escaping borrow checker | Don't know why you need it | ❌ No |
SAFETY Comment Requirements
Every unsafe block must include a SAFETY comment:
// SAFETY: ptr must be non-null and properly aligned.
// This function is only called after a null check.
unsafe { *ptr = value; }