Loading tutorials
Box, Rc, and RefCell each relax one of these rules in a controlled way. To follow that, you need the rules fresh in mind, along with the exact point where the compiler enforc5 min readBox, Rc, and RefCell one 5 min readBox<T>, the simplest smart pointer in Rust. It assumes you know Rust ownership, moves, and borrowing, basic traits and generics, and the difference between the stack and the heap. Recursive types and trait objects get their own chapters. Here we focus on what a Box is, what i4 min readBox<T> stores a value on the heap and that the owner of the box frees it. Here you will use Box to solve a concrete compiler error: a type that contains itself.5 min readVec<T> holds values of one type. You should also know why a Box<T> puts its value on the heap. The goal is to store values of different concrete types in one collection and call the same method on ea4 min readDeref trait let4 min readDeref trait from the previous chapter, the difference between &T and &mut T, and how to write a function that takes a reference parameter. It covers what the compiler does when you pass a smart pointer reference to a function that expects a different reference5 min readDrop trait, the exact order in which values are dropped, and the ways that order can surprise you.5 min readBox<T>, Deref, and Drop from earlier chapters, and that you can read basic enums and traits.5 min read&T and &mut T differ, and how to define structs with methods. It introduces the idea of interior mutability. The next chapters cover RefCell<T> and Cell<T> in detail.5 min readBox<T> and Rc<T>. You should recall that the compiler allows either one &mut T or any number of &T at a time, never both.5 min readRc<T> (several owners of one value) and RefCell<T> (borrow rules checked at runtime). Here you combine the two to get shared, mutable data in single-threaded code.4 min readCopy means: a type whose values are duplicated bit for bit on assignment, such as integers, bool, char, and tuples of4 min readRc<T> and its strong count, RefCell<T> and borrow_mut, and the Drop trait. If you need to refresh any of these, read their chapters first. The chapter shows how two Rc values can keep each other alive forever. It also shows how to spot the problem. The fix, `W5 min readRc<T>, RefCell<T>, and the combination Rc<RefCell<T>>. It also assumes you have seen how a reference cycle leaks memory. Here you will learn how Weak<T> lets one side of a link point at a value without owning it.5 min readRc<T> and RefCell<T>, and understand traits and generics at a basic level. You should also know that std::thread::spawn runs a closure on a new thread.4 min readBox<T>, Rc<T>, RefCell<T>, Weak<T>, and the Deref and Drop traits. Here you turn that material into a decision procedure. Each pointer type solves one problem. Picking the5 min read