From b6e86c715f138d235ccc8e45b964bfcbc1de0764 Mon Sep 17 00:00:00 2001 From: sunface Date: Thu, 30 Dec 2021 21:21:25 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=99=BA=E8=83=BD=E6=8C=87=E9=92=88intro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- book-contents/SUMMARY.md | 4 +- book-contents/about-book.md | 2 +- book-contents/advance/smart-pointer/intro.md | 23 +- book.toml | 2 +- deploy-gh-pages | 1 + sitemap.xml | 1083 ++++++++++++++++++ 6 files changed, 1110 insertions(+), 5 deletions(-) create mode 100644 sitemap.xml diff --git a/book-contents/SUMMARY.md b/book-contents/SUMMARY.md index b1a1d354..01d489cb 100644 --- a/book-contents/SUMMARY.md +++ b/book-contents/SUMMARY.md @@ -64,8 +64,8 @@ - [注释和文档](advance/comment.md) - [深入类型之newtype和Sized](advance/custom-type.md) - [格式化输出](advance/formatted-output.md) - - [智能指针 todo](advance/smart-pointer/intro.md) - - [Box对象(todo)](advance/smart-pointer/box.md) + - [智能指针 doing](advance/smart-pointer/intro.md) + - [Box堆对象分配)](advance/smart-pointer/box.md) - [Deref和Drop特征(todo)](advance/smart-pointer/deref-drop.md) - [Cell todo](advance/smart-pointer/cell.md) - [Rc与RefCell(todo)](advance/smart-pointer/rc-refcell.md) diff --git a/book-contents/about-book.md b/book-contents/about-book.md index bb20904f..da77fb8b 100644 --- a/book-contents/about-book.md +++ b/book-contents/about-book.md @@ -1,4 +1,4 @@ -# Rust语言圣经(The course) +# Rust语言圣经(Rust course) - 官方网址: https://course.rs - 修订时间: **尚未发行** diff --git a/book-contents/advance/smart-pointer/intro.md b/book-contents/advance/smart-pointer/intro.md index 1ad6265b..de864626 100644 --- a/book-contents/advance/smart-pointer/intro.md +++ b/book-contents/advance/smart-pointer/intro.md @@ -1,3 +1,24 @@ # 智能指针 +在各个编程语言中,指针的概念几乎都是相同的:**指针是一个包含了内存地址的变量,该内存地址引用或者指向了另外的数据**。 -部分内容借鉴了Rust book \ No newline at end of file +在Rust中,最常见的指针类型是引用,引用通过`&`符号表示。不同于其它语言,引用在Rust中被赋予了更深层次的含义那就是:借用了其它变量的值。引用本身很简单,除了指向某个值外并没有其它的功能,也不会造成性能上的额外损耗,因此是Rust中使用最多的指针类型。 + +而智能指针则不然,它虽然也号称指针,但是它是一个复杂的家伙:通过比引用更复杂的数据结构,包含比引用更多的信息,例如元数据,当前长度,最大可用长度等。总之,Rust的智能指针并不是独创,在C++或者其他语言中也存在相似的概念。 + +Rust标准库中定义的那些智能指针,虽重但强,可以提供比引用更多的功能特性,例如本章将讨论的引用计数智能指针。该智能指针允许你同时拥有同一个数据的多个所有权,它会跟踪每一个所有者并进行计数,当所有的所有者都归还后,该智能指针及指向的数据将自动被清理释放。 + +引用和智能指针的另一个不同在于前者仅仅是借用了数据,而后者往往可以拥有它们指向的数据,然后再为其它人提供服务。 + +在之前的章节中,实际上我们已经见识过多种智能指针,例如动态字符串`String`和动态数组`Vec`,它们的数据结构中不仅仅包含了指向底层数据的指针,还包含了当前长度、最大长度等信息,其中`String`智能指针还提供了一种担保信息:所有的数据都是合法的`UTF-8`格式。 + + +智能指针往往是基于结构体实现,它与我们自定义的结构体最大的区别在于它实现了`Deref`和`Drop`特征: + +- `Deref`可以让智能指针像引用那样工作,这样你就就可以写出同时支持智能指针和引用的代码, 例如`&T` +- `Drop`允许你指定智能指针超出作用域后自动执行的代码,例如做一些数据清除等收尾工作 + +鉴于智能指针在Rust中很常见,因此我们在本章不会全部讲解,而是挑选几个最常用、最有代表性的进行讲解: + +- `Box`, 可以将值分配到堆上 +- `Rc`, 引用计数类型,允许多所有权存在 +- `Ref`和`RefMut`, 允许将借用规则检查从编译期移动到运行期进行 \ No newline at end of file diff --git a/book.toml b/book.toml index 2eaf0d26..d531299d 100644 --- a/book.toml +++ b/book.toml @@ -1,7 +1,7 @@ [book] authors = ["sunface"] language = "zh-CN" -title = "Rust语言圣经(Rust学习教程)" +title = "Rust语言圣经(Rust教程 Rust Course)" src = "book-contents" [output.html] diff --git a/deploy-gh-pages b/deploy-gh-pages index a62aaabc..073c3d3b 100755 --- a/deploy-gh-pages +++ b/deploy-gh-pages @@ -5,6 +5,7 @@ mdbook build ## copy CNAME info to book dir cp CNAME ./book/ cp ./assets/*.html ./book/ +cp ./sitemap.xml ./book/ ## init git repo cd book diff --git a/sitemap.xml b/sitemap.xml new file mode 100644 index 00000000..6bb6863c --- /dev/null +++ b/sitemap.xml @@ -0,0 +1,1083 @@ + + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + + +2021-12-30 +weekly + + \ No newline at end of file