From 9c06d74365736aad110c1d6750b49f5bfc0a2b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E4=BA=94?= Date: Sat, 2 Dec 2023 13:12:14 +0800 Subject: [PATCH] Update cell-refcell.md --- src/advance/smart-pointer/cell-refcell.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/advance/smart-pointer/cell-refcell.md b/src/advance/smart-pointer/cell-refcell.md index 99d87398..3cefed33 100644 --- a/src/advance/smart-pointer/cell-refcell.md +++ b/src/advance/smart-pointer/cell-refcell.md @@ -129,7 +129,7 @@ println!("{}", x); 虽然性能一致,但代码 `1` 拥有代码 `2` 不具有的优势:它能编译成功:) -与 `Cell` 的 `zero cost` 不同,`RefCell` 其实是有一点运行期开销的,原因是它包含了一个字大小的“借用状态”指示器,该指示器在每次运行时借用时都会被修改,进而产生一点开销。 +与 `Cell` 的 `zero cost` 不同,`RefCell` 其实是有一点运行期开销的,原因是它包含了一个字节大小的“借用状态”指示器,该指示器在每次运行时借用时都会被修改,进而产生一点开销。 总之,当非要使用内部可变性时,首选 `Cell`,只有你的类型没有实现 `Copy` 时,才去选择 `RefCell`。