Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Unsafe Rust | Rust Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. Rust Fundamentals

Lesson 38 of 50

·rust

Unsafe Rust

15 minutes

Course progress76%

Unsafe Rust

unsafe blocks allow you to perform operations the compiler cannot guarantee safety for, such as dereferencing raw pointers.

fn main() {
    let mut num = 5;
    let r1 = &num as * ;
      = & num  * ;
     {
        (\
const
i32
let
r2
mut
as
mut
i32
unsafe
println!
"r1 points to: {}\", *r1); *r2 = 10; } println!(\"num is now: {}\", num); }

Use unsafe sparingly and encapsulate it in safe abstractions.

Make it stickPractice what you've learned1 quiz · 1 practical test · Optional activities from Rust FundamentalsBrowse activities
Previous lessonMutexes and Shared StateContinue to lesson 39Foreign Function Interface (FFI)Back to Rust Fundamentals curriculum