What is the difference between Rc and Arc

Rc is for single-threaded reference counting, while Arc provides thread-safe reference counting for sharing data across threads.

The difference is that Rc is for single-threaded reference counting while Arc is for thread-safe reference counting across multiple threads. Use Rc when data is confined to one thread for better performance, and Arc when you need to share ownership between threads.

use std::rc::Rc;
use std::sync::Arc;

let single_thread = Rc::new(vec![1, 2, 3]);
let multi_thread = Arc::new(vec![1, 2, 3]);