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.

Smart Pointers (Box, Rc, Arc) | Rust Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. Rust Fundamentals

Lesson 46 of 50

·rust

Smart Pointers (Box, Rc, Arc)

12 minutes

Course progress92%

Smart Pointers (Box, Rc, Arc)

  • Box<T> allocates data on the heap.
  • Rc<T> provides single‑threaded reference counting.
  • Arc<T> provides atomic reference counting for multi‑threaded scenarios.
use std::rc::Rc;
use std::sync::Arc;

fn main() {
    let  = ::();
      = Rc::();
      = Arc::();
    (\
b
Box
new
5
let
rc
new
10
let
arc
new
15
println!
"Box: {}, Rc: {}, Arc: {}\", b, rc, arc); }
Make it stickPractice what you've learned1 quiz · 1 practical test · Optional activities from Rust FundamentalsBrowse activities
Previous lessonProfiling and BenchmarkingContinue to lesson 47Interior Mutability with RefCellBack to Rust Fundamentals curriculum