Skip to content

Commit 394a3d7

Browse files
committed
txs auto checkin
1 parent 20e0c80 commit 394a3d7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

rust.tex

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3081,8 +3081,20 @@ \section{Advanced Features}
30813081
\end{frame}
30823082

30833083

3084-
Function Pointers
3085-
Returning Closures
3084+
3085+
\begin{frame}[fragile]
3086+
\frametitle{Function Pointers}
3087+
Functions coerce to the type \mintinline{rust}|fn| (with \textbf{a lowercase f}), not to be confused with the \mintinline{rust}|Fn| \textbf{closure trait}. The \mintinline{rust}|fn| type is called a function pointer. Passing functions with function pointers will allow you to use functions as arguments to other functions.
3088+
3089+
\inputminted{rust}{./code/fn1.rs}
3090+
3091+
\end{frame}
3092+
3093+
3094+
\begin{frame}[fragile]
3095+
\frametitle{Returning Closures}
3096+
Closures are represented by traits, which means you can’t return closures directly. In most cases where you might want to return a trait, you can instead use the concrete type that implements the trait as the return value of the function. However, you can’t do that with closures because they don’t have a concrete type that is returnable;
3097+
\end{frame}
30863098

30873099
\section{Multithread Web Server}
30883100
\section{Tokio}

0 commit comments

Comments
 (0)