You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trpl-zh-cn/src/ch13-00-functional-features.md

16 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Rust 中的函数式语言功能 —— 迭代器和闭包
> [ch13-00-functional-features.md](https://github.com/rust-lang/book/blob/master/second-edition/src/ch13-00-functional-features.md)
> <br>
> commit 4f2dc564851dc04b271a2260c834643dfd86c724
Rust 的设计灵感来源于很多前人的成果。影响 Rust 的其中之一就是函数式编程,在这里函数也是值并可以被用作参数或其他函数的返回值、赋值给变量等等。我们将回避解释函数式编程的具体是什么以及其优缺点,而是突出展示 Rust 中那些类似被认为是函数式的编程语言中的功能。
更具体的,我们将要涉及:
* **闭包***Closures*),一个可以储存在变量里的类似函数的结构
* **迭代器***Iterators*),一种处理元素序列的方式。。
* 如何使用这些功能来改进上一章的项目
* 这些功能的性能。**剧透高能:**他们的速度超乎想象!
这并不是一个 Rust 受函数式风格影响的完整功能列表:还有模式匹配、枚举和很多其他功能。不过掌握闭包和迭代器则是编写符合语言风格的快速的 Rust 代码的重要一环。