From 9591f935680743dfd5a1d9d62d0812697495293f Mon Sep 17 00:00:00 2001 From: Nicole L Date: Fri, 28 Feb 2025 13:20:48 -0800 Subject: [PATCH] Add speaker note about fn ptrs (#2680) --- src/closures/syntax.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/closures/syntax.md b/src/closures/syntax.md index 2a71c1f0..288370ad 100644 --- a/src/closures/syntax.md +++ b/src/closures/syntax.md @@ -30,4 +30,15 @@ fn main() { not capture any variables from their lexical environment. We will see captures next. +## More to Explore + +- The ability to store functions in variables doesn't just apply to closures, + regular functions can be put in variables and then invoked the same way that + closures can: [Example in the playground][fn-ptr]. + + - The linked example also demonstrates that closures that don't capture + anything can also coerce to a regular function pointer. + + +[fn-ptr]: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=817cbeeefc49f3d0d180a3d6d54c8bda