Loading tutorials
|x| x + 1. Here you will learn how Rust decides what a closure takes from the surrounding code, and why that decision affects what you can do with the variable afterward.2 min readmove keyword changes that choice and when you need it.2 min readFn, FnMut and FnOnce from the previous chapter. Here you will write functions that take closures and pick the right bound for each one.2 min readmove does, and how Fn, FnMut and FnOnce differ. It also assumes basic generics and trait bounds.2 min readOption, and basic Vec use. It also assumes you know closures from the previous chapters.2 min readVec and slices. It also assumes you have seen the Iterator trait and its next method.1 min readIterator trait and next, how iter() differs from into_iter(), and closure syntax. Adapters are the methods on Iterator that take one iterator and return a new one.2 min readIterator trait with next. It also assumes you have seen adapters such as map and filter.2 min readOption, and how iter() and adapters like map and filter work. Adapters build a pipeline but do no work. A consumer is an Iterator method that calls next repeatedly and produces a final value, which is 2 min readmap and filter work, that iterators are lazy, and how Option and Result behave. Here you will see how collect turns an iterator into a concrete collection.2 min readFn, FnMut and FnOnce traits, the difference between iter, iter_mut and into_iter, and the basic adapters and consumers. Here you combine them into pipelines and see how closure capture affects the whole chain.2 min readIterator trait's next method, the difference between iter, iter_mut and into_iter, and how adapters and consumers work. You also need basic generics, Option, and struct definitions.2 min readmap, filter and sum, and that you know generics and trait bounds. It explains why a chain costs about the same as a hand-written loop. It also covers where that stops being true.2 min readFn, FnMut and FnOnce traits, and the basic iterator adapters and consumers. Most closure and iterator errors come from a few causes. Once you can recognize them, the compiler's messages become easy to act on.2 min read