liveBook · Manning

Rc

Rc is Rust’s single-threaded reference-counted smart pointer for shared ownership of a value.

How 2 Manning books explain it

Code Like a Pro in Rust

Rc is Rust's single-threaded reference-counted smart-pointer type for shared ownership of a value.

How it is used
Uses Rc to share ownership of a value within one thread.
How deep it goes
Explains reference-count changes and release, contrasts atomic counters, and defers detailed Send and Sync discussion.
Examples
Demonstrates Rc in a doubly linked list and suggests implementing a reference-counted pointer with unsafe pointers.
What you can do after
Apply it via Rust’s Rc to share ownership, choosing RefCell or make_mut for different mutation needs.

Read how Code Like a Pro in Rust explains Rc →

Learn Rust in a Month of Lunches

Rc is Rust's reference-counting smart pointer type for shared ownership of data while tracking the number of active owning references.

How it is used
Shares owned data across structures or calls when unique ownership or full cloning is inconvenient.
How deep it goes
Explains construction, cloning, owner counts, weak references, cycles, and lifetime avoidance through worked examples.
Examples
Uses moved Strings, shared city names and histories, repeated function calls, owner counts, and nested city-country-world structs.
What you can do after
Apply it via std::rc::Rc to share data, inspect strong counts, and replace selected lifetime-heavy string references.

Read how Learn Rust in a Month of Lunches explains Rc →

Also covered in

What to know first

Related concepts

Questions about Rc

What is Rc?

Rc is Rust’s single-threaded reference-counted smart pointer for shared ownership of a value.

Which Manning books explain Rc?

Code Like a Pro in Rust and Learn Rust in a Month of Lunches.

What should I know before learning Rc?

Manning books that teach Rc usually introduce copy, borrow checker, garbage collection and heap first.

What is the difference between Rc and Arc?

Rc is Rust’s single-threaded reference-counted smart pointer for shared ownership of a value. Arc is Rust’s atomically reference-counted smart pointer, which enables shared ownership of a value across threads.

What is Rc a kind of?

Rc 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.

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.