]> git.proxmox.com Git - rustc.git/blob - src/doc/book/second-edition/src/ch13-00-functional-features.md
New upstream version 1.18.0+dfsg1
[rustc.git] / src / doc / book / second-edition / src / ch13-00-functional-features.md
1 # Functional Language features in Rust - Iterators and Closures
2
3 Rust's design has taken inspiration from a lot of previous work. One of Rust's
4 influences is functional programming, where functions are values that can be
5 used as arguments or return values to other functions, assigned to variables,
6 and so forth. We're going to sidestep the issue of what, exactly, functional
7 programming is or is not, and instead show off some features of Rust that
8 are similar to features in many languages referred to as functional.
9
10 More specifically, we're going to cover:
11
12 * *Closures*, a function-like construct you can store in a variable.
13 * *Iterators*, a way of processing series of elements.
14 * How to use these features to improve upon the project from the last chapter.
15 * The performance of these features. Spoiler alert: they're faster than you
16 might think!
17
18 This is not a complete list of Rust's influence from the functional style:
19 pattern matching, enums, and many other features are too. But mastering
20 closures and iterators are an important part of writing idiomatic, fast Rust
21 code.