maverick-rust-unsafe
Installation
SKILL.md
Rust Unsafe Skill
When to Use Unsafe
- FFI with C libraries
- Raw pointers for performance
- Type transmutation (rare, dangerous)
- Unsafe trait implementations
Safety Documentation
/// SAFETY: The slice is guaranteed to be non-empty by the caller.
/// This is enforced by the type system via NonEmptySlice.
unsafe fn get_first_unchecked(slice: &[i32]) -> i32 {
debug_assert!(!slice.is_empty());
*slice.get_unchecked(0)
}