From f52f243e1e9ac2506f59e211e178d9db3b063fc3 Mon Sep 17 00:00:00 2001 From: Yifu Duan Date: Mon, 26 Sep 2022 17:39:27 +0800 Subject: [PATCH] the demo code can not cache `String` but `&str` --- src/advance/functional-programing/closure.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/advance/functional-programing/closure.md b/src/advance/functional-programing/closure.md index 6dd2a4fc..81aeffc8 100644 --- a/src/advance/functional-programing/closure.md +++ b/src/advance/functional-programing/closure.md @@ -303,7 +303,7 @@ where } ``` -上面的缓存有一个很大的问题:只支持 `u32` 类型的值,若我们想要缓存 `String` 类型,显然就行不通了,因此需要将 `u32` 替换成泛型 `E`,该练习就留给读者自己完成,具体代码可以参考[这里](https://practice.rs/functional-programing/cloure.html#closure-in-structs) +上面的缓存有一个很大的问题:只支持 `u32` 类型的值,若我们想要缓存 `&str` 类型,显然就行不通了,因此需要将 `u32` 替换成泛型 `E`,该练习就留给读者自己完成,具体代码可以参考[这里](https://practice.rs/functional-programing/cloure.html#closure-in-structs) ## 捕获作用域中的值 @@ -769,4 +769,4 @@ fn factory(x:i32) -> Box i32> { 这块儿内容在进阶生命周期章节中有讲,这里就不再赘述,读者可移步[此处](https://course.rs/advance/lifetime/advance.html#闭包函数的消除规则)进行回顾。 -{{#include ../../practice.md}} \ No newline at end of file +{{#include ../../practice.md}}