What Can You Do Inside an unsafe Block?

An unsafe block in Rust allows you to perform operations like dereferencing raw pointers or calling unsafe functions by manually guaranteeing their safety.

Inside an unsafe block, you can perform operations that the Rust compiler cannot guarantee are safe, such as dereferencing raw pointers, calling unsafe functions, or accessing mutable static variables.

unsafe {
    let ptr: *const i32 = &42;
    let value = *ptr; // Dereferencing a raw pointer
}

This block tells the compiler you have manually verified the safety of these operations.