Arc
Arc is Rust’s atomically reference-counted smart pointer, which enables shared ownership of a value across threads.
Code Like a Pro in Rust
Arc is a Rust thread-safe reference-counted smart pointer for shared ownership of a value across threads.
- How it is used
- Uses Arc for shared ownership across threads and shared state in parallel tests.
- How deep it goes
- Explains reference counts, atomic costs, synchronization, and clone-on-write, while deferring detailed Send and Sync treatment.
- Examples
- Demonstrates a global AtomicI32 test counter wrapped in Arc and initialized with lazy_static, then shows an alternative without Arc.
- What you can do after
- Apply Arc to shared ownership and choose synchronization or clone-on-write for appropriate mutation needs.
Rust Web Development
Arc is Rust’s atomically reference-counted shared pointer type, which allows multiple owners to access heap-allocated data.
- How it is used
- Shares one heap-allocated application store across multithreaded REST handlers without copying the store.
- How deep it goes
- Explains heap placement, pointer cloning, reference-count changes, and dropping at zero; defers mutation safety to locks.
- Examples
- Uses a HashMap-backed question store wrapped in Arc<RwLock<...>>.
- What you can do after
- Apply it by wrapping a shared store in Arc and pairing it with a lock when handlers need mutation.
Learn Rust in a Month of Lunches
Arc is Rust's atomically reference-counted smart pointer for sharing ownership of a value safely across threads.
- How it is used
- Shares ownership of values across threads while coordinating access through thread-safe types.
- How deep it goes
- Defines atomic operations and demonstrates cloning, locking, spawning, joining, and repeated shared-counter updates.
- Examples
- Uses Arc<Mutex<i32>> counters, two-thread increments, ten-thread loops, and helper functions that construct and clone Arcs.
- What you can do after
- Build shared counters with Arc, Mutex, spawned threads, cloned owners, and joined handles.
Also covered in
What to know first
- lockingLocking is a synchronization technique that controls concurrent access to a shared resource or protected operation.
- borrow checkerA borrow checker is a compiler component that statically enforces ownership, borrowing, and reference-lifetime rules to prevent invalid memory access.
- heapA heap is a runtime memory region from which dynamically allocated data is obtained and whose allocation and lifetime are managed separately from function call frames.
Related concepts
- Rcalternative to · Rc is Rust’s single-threaded reference-counted smart pointer for shared ownership of a value.
- smart pointerkind of · A smart pointer is a pointer-like object that manages or mediates access to a referenced resource, often providing ownership, lifetime, or safety behavior.
- atomicityuses · Atomicity is the property that an operation or group of operations takes effect as an indivisible whole, without observable partial effects.
- reference-counted pointerkind of · A reference-counted pointer is a pointer-like value whose referenced allocation is reclaimed when its tracked reference count reaches zero.
- lockinghas part · Locking is a synchronization technique that controls concurrent access to a shared resource or protected operation.
- rwlockhas part · An RwLock is a synchronization primitive that permits multiple concurrent readers or one exclusive writer to access protected data.
Questions about Arc
What is Arc?
Arc is Rust’s atomically reference-counted smart pointer, which enables shared ownership of a value across threads.
Which Manning books explain Arc?
Code Like a Pro in Rust, Rust Web Development and Learn Rust in a Month of Lunches.
What should I know before learning Arc?
Manning books that teach Arc usually introduce locking, borrow checker and heap first.
What is the difference between Arc and Rc?
Arc is Rust’s atomically reference-counted smart pointer, which enables shared ownership of a value across threads. Rc is Rust’s single-threaded reference-counted smart pointer for shared ownership of a value.
What is Arc a kind of?
Arc is a kind of smart pointer. A smart pointer is a pointer-like object that manages or mediates access to a referenced resource, often providing ownership, lifetime, or safety behavior.
What are the parts of Arc?
Arc includes locking and rwlock.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


