Rc
Rc is Rust’s single-threaded reference-counted smart pointer for shared ownership of a value.
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
- Provides single-threaded shared ownership for structures such as doubly linked lists.
- How deep it goes
- Explains count increments and decrements, then shows an Rc-based node representation; leaves raw-pointer implementation as an exercise.
- Examples
- Uses a doubly linked list whose node references are `Rc<RefCell<ListItem<T>>>`.
- What you can do after
- Apply it via `Rc` for single-threaded shared ownership, pairing it with `RefCell` when shared nodes need mutation.
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.
Related concepts
- Arcalternative to · Arc is Rust’s atomically reference-counted smart pointer for shared ownership of a value across threads.
- 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.
- reference countinguses · Reference counting is a memory-management technique that tracks references to an object or value and can reclaim it when its reference count reaches zero.
- lifetime annotationaddresses · In Rust, a lifetime annotation is syntax that names or relates the validity lifetimes of references in types and function signatures.
- ownershipaddresses · Ownership is a programming-language model that assigns responsibility for controlling a value or resource, including its lifetime and eventual cleanup.
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.

