Files
docs-rust/ch13/ch13-00-functional-features.html
2026-06-22 21:27:36 +05:30

31 lines
1.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Functional Language Features: Iterators and Closures</title>
</head>
<body>
<h1 id="functional-language-features-iterators-and-closures"><a class="header" href="#functional-language-features-iterators-and-closures">Functional Language Features: Iterators and Closures</a></h1>
<p>Rusts design has taken inspiration from many existing languages and
techniques, and one significant influence is <em>functional programming</em>.
Programming in a functional style often includes using functions as values by
passing them in arguments, returning them from other functions, assigning them
to variables for later execution, and so forth.</p>
<p>In this chapter, we wont debate the issue of what functional programming is or
isnt but will instead discuss some features of Rust that are similar to
features in many languages often referred to as functional.</p>
<p>More specifically, well cover:</p>
<ul>
<li><em>Closures</em>, a function-like construct you can store in a variable</li>
<li><em>Iterators</em>, a way of processing a series of elements</li>
<li>How to use closures and iterators to improve the I/O project in Chapter 12</li>
<li>The performance of closures and iterators (spoiler alert: Theyre faster than
you might think!)</li>
</ul>
<p>Weve already covered some other Rust features, such as pattern matching and
enums, that are also influenced by the functional style. Because mastering
closures and iterators is an important part of writing fast, idiomatic, Rust
code, well devote this entire chapter to them.</p>
</body>
</html>