Loading tutorials
free calls. It does this by giving every value exactly one owner. That rule prevents a whole class of memory bugs, but on its own it makes ordinary code awkward. Borrowing is the feature that removes the awkwardness. This chapter sho5 min readString, Vec, and &str, the difference between stack and heap, and how to run a program with cargo. It also assumes you have seen that assigning or passing a String by value moves ownership. This chapter covers shared references. Mu5 min readString and Vec work, the difference between stack and heap memory, and how to build a program with cargo. It also assumes you have read the previous chapter on shared references (&T). Here you will learn how to lend a value out so the borrow6 min readString and &str, and have read the earlier chapters on moves, &T, and &mut T.6 min read&T) work, how String, Vec, and &str differ, and that a value has one owner. It also assumes you can build and run a program with cargo. Here you will learn what a slice is, how it relates to the borrowing rules, and where slices go wrong.6 min read&T) and mutable (&mut T) references, and the rule that a value has either many readers or one writer. You should also be able to read a cargo build error. Here you will learn what a dangling reference is, the forms it takes in Rust cod5 min read&T) and mutable (&mut T) references work, and that you know the rule of many readers or one writer. It also assumes you can read a basic compiler error. The question here is narrower: for how many lines does a borrow count as active?6 min read&T) and mutable references (&mut T) work. You should know the rule of many readers or one writer, and why returning a reference to a local variable is rejected. This chapter shows how to write lifetime annotations in function signatures, and what th5 min read&T and &mut T. It also assumes you know the rule that a value has either many shared borrows or one mutable borrow at a time, and that you understand non-lexical lifetimes (NLL), which end a borrow at its last use.5 min read&T), mutable references (&mut T), the "many readers or one writer" rule, and the lifetime elision rules. Here you will use them to decide what type a function parameter should have.6 min read&T), mutable references (&mut T), and the rule that a value has either many readers or one writer at a time. It also assumes you can use Rc for shared ownership at a basic level. Here you will see how RefCell<T> moves that rule from compile ti5 min read&T), mutable references (&mut T), the "many readers or one writer" rule, and basic lifetimes. You should also be able to run cargo build and read its output.6 min read