RustBrock/Iterators and Closures.md
2025-02-24 13:11:28 -07:00

20 lines
1.1 KiB
Markdown

# Functional Language Features: Iterators and Closures
Rust's design has taken inspiration from many exisitng languages and techniques
One significant influence is *functional programming*
Programming in a functional style often include using functions as values by passing them in args, returning them form other unfcitons, assigning them to varaibles for later execution and so forth.
This chapter/section won't debate the issue of what functional programming is or isn't.
It will discuss some features of Rust that are similar to features in many languages often referred to as functional
It will cover:
- [*Closures*](./Closures.md) - a function-like construct you can store in a variable
- [*Iterators*](./Iterators.md) - a way of processing a series of elements
- How to use colsure and iterators to improve the I/O project (minigrep)
- The preformance of closures and iterators (Spoiler alert: they are faster than you might think!)
We have already covered some other Rust freatures, such as pattern matchin and enums, that are also influenced by the functional style.
Mastering closures and iterators is an improtant part of wiritng idiomatic, fast Rust code.