以下の内容はhttps://yohhoy.hatenadiary.jp/entry/20160106/p1より取得しました。


ラムダ式はFnOnce/FnMut/Fnトレイト実装の糖衣構文

プログラミング言語Rustのラムダ式(lambda expression)は、トレイトFnOnce / FnMut / Fn を実装(impl)したクロージャ(closure)を作り出す、一種の糖衣構文(syntax sugar)として機能する。

Closure implementation
Rust's implementation of closures is a bit different than other languages. They are effectively syntax sugar for traits. You'll want to make sure to have read the traits chapter before this one, as well as the chapter on trait objects.

(snip)

The || {} syntax for closures is sugar for these three traits. Rust will generate a struct for the environment, impl the appropriate trait, and then use it.

https://doc.rust-lang.org/book/closures.html

関連URL




以上の内容はhttps://yohhoy.hatenadiary.jp/entry/20160106/p1より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14