From a2eb91103ea1fc5b61909bbd3483b9dddf9db9bf Mon Sep 17 00:00:00 2001
From: weihanglo
Date: Tue, 6 Aug 2024 03:51:14 +0000
Subject: [PATCH] deploy: f0edaf9fdf48db7668fcb5626cd93e59347cf120
---
index.html | 2 +-
print.html | 2 +-
searchindex.js | 2 +-
searchindex.json | 2 +-
title-page.html | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/index.html b/index.html
index a15eab67..4c81098e 100644
--- a/index.html
+++ b/index.html
@@ -143,7 +143,7 @@ 來安裝或更新 Rust。
本書的 HTML 格式可以在線上閱讀:https://doc.rust-lang.org/stable/book/(正體中文版)。而離線版則包含在 rustup
安裝的 Rust 中,輸入 rustup docs --book
就能開啟。
-社群中也有提供本書的各種[譯本]。
+社群中也有提供本書的各種譯本。
本書也有由 No Starch Press 出版平裝與電子版格式。
🚨 想要更有互動的學習體驗?來嘗試不同的 Rust Book,賣點有:隨堂測驗、重點提示、視覺化呈現,更多都在 https://rust-book.cs.brown.edu
diff --git a/print.html b/print.html
index db5acf27..a32e7bf1 100644
--- a/print.html
+++ b/print.html
@@ -144,7 +144,7 @@ 來安裝或更新 Rust。
本書的 HTML 格式可以在線上閱讀:https://doc.rust-lang.org/stable/book/(正體中文版)。而離線版則包含在 rustup
安裝的 Rust 中,輸入 rustup docs --book
就能開啟。
-社群中也有提供本書的各種[譯本]。
+社群中也有提供本書的各種譯本。
本書也有由 No Starch Press 出版平裝與電子版格式。
🚨 想要更有互動的學習體驗?來嘗試不同的 Rust Book,賣點有:隨堂測驗、重點提示、視覺化呈現,更多都在 https://rust-book.cs.brown.edu
diff --git a/searchindex.js b/searchindex.js
index 0b15a793..4d528fa6 100644
--- a/searchindex.js
+++ b/searchindex.js
@@ -1 +1 @@
-Object.assign(window.search, {"doc_urls":["title-page.html#rust-程式設計語言","foreword.html#前言","ch00-00-introduction.html#介紹","ch00-00-introduction.html#rust-適用於誰","ch00-00-introduction.html#開發團隊","ch00-00-introduction.html#學生","ch00-00-introduction.html#公司","ch00-00-introduction.html#開源開發者","ch00-00-introduction.html#重視速度與穩定性的開發者","ch00-00-introduction.html#本書寫給誰看","ch00-00-introduction.html#如何閱讀本書","ch00-00-introduction.html#原始碼","ch01-00-getting-started.html#開始入門","ch01-01-installation.html#安裝教學","ch01-01-installation.html#命令列標記","ch01-01-installation.html#在-linux-或-macos-上安裝-rustup","ch01-01-installation.html#在-windows-上安裝-rustup","ch01-01-installation.html#疑難排除","ch01-01-installation.html#更新與解除安裝","ch01-01-installation.html#本地端技術文件","ch01-02-hello-world.html#hello-world","ch01-02-hello-world.html#建立專案目錄","ch01-02-hello-world.html#編寫並執行-rust-程式","ch01-02-hello-world.html#分析這支-rust-程式","ch01-02-hello-world.html#編譯和執行是不同的步驟","ch01-03-hello-cargo.html#hello-cargo","ch01-03-hello-cargo.html#使用-cargo-建立專案","ch01-03-hello-cargo.html#建構並執行-cargo-專案","ch01-03-hello-cargo.html#建構發佈版本release","ch01-03-hello-cargo.html#將-cargo-視為常規","ch01-03-hello-cargo.html#總結","ch02-00-guessing-game-tutorial.html#設計猜謎遊戲程式","ch02-00-guessing-game-tutorial.html#設置新專案","ch02-00-guessing-game-tutorial.html#處理猜測","ch02-00-guessing-game-tutorial.html#透過變數儲存數值","ch02-00-guessing-game-tutorial.html#取得使用者輸入","ch02-00-guessing-game-tutorial.html#使用-result-處理可能的錯誤","ch02-00-guessing-game-tutorial.html#透過-println-佔位符印出數值","ch02-00-guessing-game-tutorial.html#測試第一個部分","ch02-00-guessing-game-tutorial.html#產生祕密數字","ch02-00-guessing-game-tutorial.html#使用-crate-來取得更多功能","ch02-00-guessing-game-tutorial.html#產生隨機數字","ch02-00-guessing-game-tutorial.html#將猜測的數字與祕密數字做比較","ch02-00-guessing-game-tutorial.html#透過迴圈來允許多次猜測","ch02-00-guessing-game-tutorial.html#猜對後離開","ch02-00-guessing-game-tutorial.html#處理無效輸入","ch02-00-guessing-game-tutorial.html#總結","ch03-00-common-programming-concepts.html#常見程式設計概念","ch03-01-variables-and-mutability.html#變數與可變性","ch03-01-variables-and-mutability.html#常數","ch03-01-variables-and-mutability.html#遮蔽shadowing","ch03-02-data-types.html#資料型別","ch03-02-data-types.html#純量型別","ch03-02-data-types.html#複合型別","ch03-03-how-functions-work.html#函式","ch03-03-how-functions-work.html#參數","ch03-03-how-functions-work.html#陳述式與表達式","ch03-03-how-functions-work.html#函式回傳值","ch03-04-comments.html#註解","ch03-05-control-flow.html#控制流程","ch03-05-control-flow.html#if-表達式","ch03-05-control-flow.html#使用迴圈重複執行","ch03-05-control-flow.html#總結","ch04-00-understanding-ownership.html#理解所有權","ch04-01-what-is-ownership.html#什麼是所有權","ch04-01-what-is-ownership.html#堆疊stack與堆積heap","ch04-01-what-is-ownership.html#所有權規則","ch04-01-what-is-ownership.html#變數作用域","ch04-01-what-is-ownership.html#string-型別","ch04-01-what-is-ownership.html#記憶體與配置","ch04-01-what-is-ownership.html#所有權與函式","ch04-01-what-is-ownership.html#回傳值與作用域","ch04-02-references-and-borrowing.html#參考與借用","ch04-02-references-and-borrowing.html#可變參考","ch04-02-references-and-borrowing.html#迷途參考","ch04-02-references-and-borrowing.html#參考規則","ch04-03-slices.html#切片型別","ch04-03-slices.html#字串切片","ch04-03-slices.html#其他切片","ch04-03-slices.html#總結","ch05-00-structs.html#透過結構體組織相關資料","ch05-01-defining-structs.html#定義與實例化結構體","ch05-01-defining-structs.html#用欄位初始化簡寫語法","ch05-01-defining-structs.html#使用結構體更新語法從其他結構體建立實例","ch05-01-defining-structs.html#使用無名稱欄位的元組結構體來建立不同型別","ch05-01-defining-structs.html#無任何欄位的類單元結構體","ch05-01-defining-structs.html#結構體資料的所有權","ch05-02-example-structs.html#使用結構體的程式範例","ch05-02-example-structs.html#使用元組重構","ch05-02-example-structs.html#使用結構體重構賦予更多意義","ch05-02-example-structs.html#使用推導特徵實現更多功能","ch05-03-method-syntax.html#方法語法","ch05-03-method-syntax.html#定義方法","ch05-03-method-syntax.html#--運算子跑去哪了","ch05-03-method-syntax.html#擁有更多參數的方法","ch05-03-method-syntax.html#關聯函式","ch05-03-method-syntax.html#多重-impl-區塊","ch05-03-method-syntax.html#總結","ch06-00-enums.html#列舉與模式配對","ch06-01-defining-an-enum.html#定義列舉","ch06-01-defining-an-enum.html#列舉數值","ch06-01-defining-an-enum.html#option-列舉相對於空值的優勢","ch06-02-match.html#match-控制流建構子","ch06-02-match.html#綁定數值的模式","ch06-02-match.html#配對-option","ch06-02-match.html#配對必須是徹底的","ch06-02-match.html#catch-all-模式與-_-佔位符","ch06-03-if-let.html#透過-if-let-簡化控制流","ch06-03-if-let.html#總結","ch07-00-managing-growing-projects-with-packages-crates-and-modules.html#透過套件crate-與模組管理成長中的專案","ch07-01-packages-and-crates.html#套件與-crates","ch07-02-defining-modules-to-control-scope-and-privacy.html#定義模組來控制作用域與隱私權","ch07-02-defining-modules-to-control-scope-and-privacy.html#模組懶人包","ch07-02-defining-modules-to-control-scope-and-privacy.html#組織相關程式碼成模組","ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html#參考模組項目的路徑","ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html#使用-pub-關鍵字公開路徑","ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html#使用-super-作為相對路徑的開頭","ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html#公開結構體與列舉","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#透過-use-關鍵字引入路徑","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#建立慣用的-use-路徑","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#使用-as-關鍵字提供新名稱","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#使用-pub-use-重新匯出名稱","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#使用外部套件","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#使用巢狀路徑來清理大量的-use-行數","ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#全域運算子","ch07-05-separating-modules-into-different-files.html#將模組拆成不同檔案","ch07-05-separating-modules-into-different-files.html#其他種的檔案路徑","ch07-05-separating-modules-into-different-files.html#總結","ch08-00-common-collections.html#常見集合","ch08-01-vectors.html#透過向量儲存列表","ch08-01-vectors.html#建立新的向量","ch08-01-vectors.html#更新向量","ch08-01-vectors.html#讀取向量元素","ch08-01-vectors.html#遍歷向量的元素","ch08-01-vectors.html#使用列舉來儲存多種型別","ch08-01-vectors.html#釋放向量的同時也會釋放其元素","ch08-02-strings.html#透過字串儲存-utf-8-編碼的文字","ch08-02-strings.html#什麼是字串","ch08-02-strings.html#建立新的字串","ch08-02-strings.html#更新字串","ch08-02-strings.html#索引字串","ch08-02-strings.html#字串切片","ch08-02-strings.html#遍歷字串的方法","ch08-02-strings.html#字串並不簡單","ch08-03-hash-maps.html#透過雜湊映射儲存鍵值配對","ch08-03-hash-maps.html#建立新的雜湊映射","ch08-03-hash-maps.html#取得雜湊映射的數值","ch08-03-hash-maps.html#雜湊映射與所有權","ch08-03-hash-maps.html#更新雜湊映射","ch08-03-hash-maps.html#雜湊函式","ch08-03-hash-maps.html#總結","ch09-00-error-handling.html#錯誤處理","ch09-01-unrecoverable-errors-with-panic.html#對無法復原的錯誤使用-panic","ch09-01-unrecoverable-errors-with-panic.html#恐慌時該解開堆疊還是直接終止","ch09-01-unrecoverable-errors-with-panic.html#使用-panic-backtrace","ch09-02-recoverable-errors-with-result.html#result-與可復原的錯誤","ch09-02-recoverable-errors-with-result.html#配對不同種的錯誤","ch09-02-recoverable-errors-with-result.html#除了使用-match-配對-result-以外的方式","ch09-02-recoverable-errors-with-result.html#錯誤發生時產生恐慌的捷徑unwrap-與-expect","ch09-02-recoverable-errors-with-result.html#傳播錯誤","ch09-03-to-panic-or-not-to-panic.html#要-panic-還是不要-panic","ch09-03-to-panic-or-not-to-panic.html#範例程式碼原型與測試","ch09-03-to-panic-or-not-to-panic.html#當你知道的比編譯器還多的時候","ch09-03-to-panic-or-not-to-panic.html#錯誤處理的指導原則","ch09-03-to-panic-or-not-to-panic.html#建立自訂型別來驗證","ch09-03-to-panic-or-not-to-panic.html#總結","ch10-00-generics.html#泛型型別特徵與生命週期","ch10-00-generics.html#提取函數來減少重複性","ch10-01-syntax.html#泛型資料型別","ch10-01-syntax.html#在函式中定義","ch10-01-syntax.html#在結構體中定義","ch10-01-syntax.html#在列舉中定義","ch10-01-syntax.html#在方法中定義","ch10-01-syntax.html#使用泛型的程式碼效能","ch10-02-traits.html#特徵定義共同行為","ch10-02-traits.html#定義特徵","ch10-02-traits.html#為型別實作特徵","ch10-02-traits.html#預設實作","ch10-02-traits.html#特徵作為參數","ch10-02-traits.html#回傳有實作特徵的型別","ch10-02-traits.html#透過特徵界限來選擇性實作方法","ch10-03-lifetime-syntax.html#透過生命週期驗證參考","ch10-03-lifetime-syntax.html#透過生命週期預防迷途參考","ch10-03-lifetime-syntax.html#借用檢查器","ch10-03-lifetime-syntax.html#函式中的泛型生命週期","ch10-03-lifetime-syntax.html#生命週期詮釋語法","ch10-03-lifetime-syntax.html#函式簽名中的生命週期詮釋","ch10-03-lifetime-syntax.html#深入理解生命週期","ch10-03-lifetime-syntax.html#結構體定義中的生命週期詮釋","ch10-03-lifetime-syntax.html#生命週期省略","ch10-03-lifetime-syntax.html#在方法定義中的生命週期詮釋","ch10-03-lifetime-syntax.html#靜態生命週期","ch10-03-lifetime-syntax.html#組合泛型型別參數特徵界限與生命週期","ch10-03-lifetime-syntax.html#總結","ch11-00-testing.html#編寫自動化測試","ch11-01-writing-tests.html#如何寫測試","ch11-01-writing-tests.html#測試函式剖析","ch11-01-writing-tests.html#透過-assert-巨集檢查結果","ch11-01-writing-tests.html#透過-assert_eq-與-assert_ne-macros-測試相等","ch11-01-writing-tests.html#加入自訂失敗訊息","ch11-01-writing-tests.html#透過-should_panic-檢查恐慌","ch11-01-writing-tests.html#在測試中使用-result","ch11-02-running-tests.html#控制程式如何執行","ch11-02-running-tests.html#平行或接續執行測試","ch11-02-running-tests.html#顯示函式輸出結果","ch11-02-running-tests.html#透過名稱來執行部分測試","ch11-02-running-tests.html#忽略某些測試除非特別指定","ch11-03-test-organization.html#測試組織架構","ch11-03-test-organization.html#單元測試","ch11-03-test-organization.html#整合測試","ch11-03-test-organization.html#總結","ch12-00-an-io-project.html#io-專案建立一個命令列程式","ch12-01-accepting-command-line-arguments.html#接受命令列引數","ch12-01-accepting-command-line-arguments.html#讀取引數數值","ch12-01-accepting-command-line-arguments.html#args-函式與無效的-unicode","ch12-01-accepting-command-line-arguments.html#將引數數值儲存至變數","ch12-02-reading-a-file.html#讀取檔案","ch12-03-improving-error-handling-and-modularity.html#透過重構來改善模組性與錯誤處理","ch12-03-improving-error-handling-and-modularity.html#分開執行檔專案的任務","ch12-03-improving-error-handling-and-modularity.html#使用-clone-的權衡取捨","ch12-03-improving-error-handling-and-modularity.html#修正錯誤處理","ch12-03-improving-error-handling-and-modularity.html#從-main-提取邏輯","ch12-03-improving-error-handling-and-modularity.html#將程式碼拆到函式庫-crate","ch12-04-testing-the-librarys-functionality.html#透過測試驅動開發完善函式庫功能","ch12-04-testing-the-librarys-functionality.html#編寫失敗的測試","ch12-04-testing-the-librarys-functionality.html#寫出讓測試成功的程式碼","ch12-05-working-with-environment-variables.html#處理環境變數","ch12-05-working-with-environment-variables.html#寫個不區分大小寫的-search-函式的失敗測試","ch12-05-working-with-environment-variables.html#實作-search_case_insensitive-函式","ch12-06-writing-to-stderr-instead-of-stdout.html#將錯誤訊息寫入標準錯誤而非標準輸出","ch12-06-writing-to-stderr-instead-of-stdout.html#檢查該在哪裡寫錯誤","ch12-06-writing-to-stderr-instead-of-stdout.html#將錯誤印出至標準錯誤","ch12-06-writing-to-stderr-instead-of-stdout.html#總結","ch13-00-functional-features.html#函式語言功能疊代器與閉包","ch13-01-closures.html#閉包獲取其環境的匿名函式","ch13-01-closures.html#透過閉包獲取環境","ch13-01-closures.html#閉包型別推導與詮釋","ch13-01-closures.html#獲取參考或移動所有權","ch13-01-closures.html#fn-特徵以及將獲取的數值移出閉包","ch13-02-iterators.html#使用疊代器來處理一系列的項目","ch13-02-iterators.html#iterator-特徵與-next-方法","ch13-02-iterators.html#消耗疊代器的方法","ch13-02-iterators.html#產生其他疊代器的方法","ch13-02-iterators.html#使用閉包獲取它們的環境","ch13-03-improving-our-io-project.html#改善我們的-io-專案","ch13-03-improving-our-io-project.html#使用疊代器移除-clone","ch13-03-improving-our-io-project.html#透過疊代配接器讓程式碼更清楚","ch13-03-improving-our-io-project.html#迴圈與疊代器之間的選擇","ch13-04-performance.html#比較效能迴圈-vs-疊代器","ch13-04-performance.html#總結","ch14-00-more-about-cargo.html#更多關於-cargo-與-cratesio-的內容","ch14-01-release-profiles.html#透過發佈設定檔自訂建構","ch14-02-publishing-to-crates-io.html#發佈-crate-到-cratesio","ch14-02-publishing-to-crates-io.html#寫上有幫助的技術文件註解","ch14-02-publishing-to-crates-io.html#透過-pub-use-匯出理想的公開-api","ch14-02-publishing-to-crates-io.html#設定-cratesio-帳號","ch14-02-publishing-to-crates-io.html#新增詮釋資料到新的-crate","ch14-02-publishing-to-crates-io.html#發佈至-cratesio","ch14-02-publishing-to-crates-io.html#對現有-crate-發佈新版本","ch14-02-publishing-to-crates-io.html#透過-cargo-yank-棄用-cratesio-的版本","ch14-03-cargo-workspaces.html#cargo-工作空間","ch14-03-cargo-workspaces.html#建立工作空間","ch14-03-cargo-workspaces.html#在工作空間中建立第二個套件","ch14-04-installing-binaries.html#透過-cargo-install-安裝執行檔","ch14-05-extending-cargo.html#透過自訂命令來擴展-cargo-的功能","ch14-05-extending-cargo.html#總結","ch15-00-smart-pointers.html#智慧指標","ch15-01-box.html#使用-box-指向堆積上的資料","ch15-01-box.html#使用-box-儲存資料到堆積上","ch15-01-box.html#透過-box-建立遞迴型別","ch15-02-deref.html#透過-deref-特徵將智慧指標視為一般參考","ch15-02-deref.html#追蹤指標的數值","ch15-02-deref.html#像參考般使用-box","ch15-02-deref.html#定義我們自己的智慧指標","ch15-02-deref.html#透過實作-deref-特徵來將一個型別能像參考般對待","ch15-02-deref.html#函式與方法的隱式強制解參考","ch15-02-deref.html#強制解參考如何處理可變性","ch15-03-drop.html#透過-drop-特徵執行清除程式碼","ch15-03-drop.html#透過-stdmemdrop-提早釋放數值","ch15-04-rc.html#rc-參考計數智慧指標","ch15-04-rc.html#使用-rc-來分享資料","ch15-04-rc.html#克隆-rc-實例會增加其參考計數","ch15-05-interior-mutability.html#refcell-與內部可變性模式","ch15-05-interior-mutability.html#透過-refcell-在執行時強制檢測借用規則","ch15-05-interior-mutability.html#內部可變性不可變數值的可變借用","ch15-05-interior-mutability.html#組合-rc-與-refcell-來擁有多個可變資料的擁有者","ch15-06-reference-cycles.html#參考循環會導致記憶體泄漏","ch15-06-reference-cycles.html#產生參考循環","ch15-06-reference-cycles.html#避免參考循環將-rc-轉換成-weak","ch15-06-reference-cycles.html#總結","ch16-00-concurrency.html#無懼並行","ch16-01-threads.html#使用執行緒同時執行程式碼","ch16-01-threads.html#透過-spawn-建立新的執行緒","ch16-01-threads.html#使用-join-等待所有執行緒完成","ch16-01-threads.html#透過執行緒使用-move-閉包","ch16-02-message-passing.html#使用訊息傳遞在執行緒間傳送資料","ch16-02-message-passing.html#通道與所有權轉移","ch16-02-message-passing.html#傳送多重數值並觀察接收者等待","ch16-02-message-passing.html#透過克隆發送者來建立多重生產者","ch16-03-shared-state.html#共享狀態並行","ch16-03-shared-state.html#使用互斥鎖在同時間只允許一條執行緒存取資料","ch16-03-shared-state.html#refcellrc-與-mutexarc-之間的相似度","ch16-04-extensible-concurrency-sync-and-send.html#可延展的並行與-sync-及-send-特徵","ch16-04-extensible-concurrency-sync-and-send.html#透過-send-來允許所有權能在執行緒間轉移","ch16-04-extensible-concurrency-sync-and-send.html#透過-sync-來允許多重執行緒存取","ch16-04-extensible-concurrency-sync-and-send.html#手動實作-send-與-sync-是不安全的","ch16-04-extensible-concurrency-sync-and-send.html#總結","ch17-00-oop.html#rust-的物件導向程式設計特色","ch17-01-what-is-oo.html#物件導向語言的特色","ch17-01-what-is-oo.html#物件包含資料與行為","ch17-01-what-is-oo.html#隱藏實作細節的封裝","ch17-01-what-is-oo.html#作為型別系統與程式碼共享來繼承","ch17-01-what-is-oo.html#多型","ch17-02-trait-objects.html#允許不同型別數值的特徵物件","ch17-02-trait-objects.html#定義共同行為的特徵","ch17-02-trait-objects.html#實作特徵","ch17-02-trait-objects.html#特徵物件執行動態調度","ch17-03-oo-design-patterns.html#實作物件導向設計模式","ch17-03-oo-design-patterns.html#定義-post-並在草稿階段建立新實例","ch17-03-oo-design-patterns.html#儲存文章內容的文字","ch17-03-oo-design-patterns.html#確保文章草稿的內容為空","ch17-03-oo-design-patterns.html#請求文章審核來變更它的狀態","ch17-03-oo-design-patterns.html#透過-approve-改變-content-的行為","ch17-03-oo-design-patterns.html#狀態模式的權衡取捨","ch17-03-oo-design-patterns.html#總結","ch18-00-patterns.html#模式與配對","ch18-01-all-the-places-for-patterns.html#所有能使用模式的地方","ch18-01-all-the-places-for-patterns.html#match-分支","ch18-01-all-the-places-for-patterns.html#if-let-條件表達式","ch18-01-all-the-places-for-patterns.html#while-let-條件迴圈","ch18-01-all-the-places-for-patterns.html#for-迴圈","ch18-01-all-the-places-for-patterns.html#let-陳述式","ch18-01-all-the-places-for-patterns.html#函式參數","ch18-02-refutability.html#可反駁性何時模式可能會配對失敗","ch18-03-pattern-syntax.html#模式語法","ch18-03-pattern-syntax.html#配對字面值","ch18-03-pattern-syntax.html#配對變數名稱","ch18-03-pattern-syntax.html#多重模式","ch18-03-pattern-syntax.html#透過--配對數值範圍","ch18-03-pattern-syntax.html#解構拆開數值","ch18-03-pattern-syntax.html#忽略模式中的數值","ch18-03-pattern-syntax.html#提供額外條件的配對守護","ch18-03-pattern-syntax.html#-綁定","ch18-03-pattern-syntax.html#總結","ch19-00-advanced-features.html#進階特色","ch19-01-unsafe-rust.html#不安全的-rust","ch19-01-unsafe-rust.html#不安全的超能力","ch19-01-unsafe-rust.html#對裸指標解參考","ch19-01-unsafe-rust.html#呼叫不安全函式或方法","ch19-01-unsafe-rust.html#存取或修改可變的靜態變數","ch19-01-unsafe-rust.html#實作不安全特徵","ch19-01-unsafe-rust.html#存取聯合體的欄位","ch19-01-unsafe-rust.html#何時該用不安全程式碼","ch19-02-advanced-traits.html#進階特徵","ch19-02-advanced-traits.html#利用關聯型別在特徵定義中指定佔位符型別","ch19-02-advanced-traits.html#預設泛型型別參數與運算子重載","ch19-02-advanced-traits.html#消除歧義的完全限定語法呼叫同名的方法","ch19-02-advanced-traits.html#使用超特徵要求在一個特徵內有另一特徵的功能","ch19-02-advanced-traits.html#使用新型別模式替外部型別實作外部特徵","ch19-03-advanced-types.html#進階型別","ch19-03-advanced-types.html#透過新型別模式達成型別安全與抽象","ch19-03-advanced-types.html#透過型別別名建立型別同義詞","ch19-03-advanced-types.html#永不回傳的永不型別","ch19-03-advanced-types.html#動態大小型別與-sized-特徵","ch19-04-advanced-functions-and-closures.html#進階函式與閉包","ch19-04-advanced-functions-and-closures.html#函式指標","ch19-04-advanced-functions-and-closures.html#回傳閉包","ch19-05-macros.html#巨集","ch19-05-macros.html#巨集與函式的差異","ch19-05-macros.html#使用-macro_rules-宣告式巨集做普通的超程式設計","ch19-05-macros.html#使用程序式巨集從屬性產生程式碼","ch19-05-macros.html#如何撰寫自訂的-derive-巨集","ch19-05-macros.html#類屬性巨集","ch19-05-macros.html#類函式巨集","ch19-05-macros.html#總結","ch20-00-final-project-a-web-server.html#最終專案建立多執行緒網頁伺服器","ch20-01-single-threaded.html#建立單一執行緒的網頁伺服器","ch20-01-single-threaded.html#監聽-tcp-連線","ch20-01-single-threaded.html#讀取請求","ch20-01-single-threaded.html#仔細觀察-http-請求","ch20-01-single-threaded.html#寫入回應","ch20-01-single-threaded.html#回傳真正的-html","ch20-01-single-threaded.html#驗證請求並選擇性地回應","ch20-01-single-threaded.html#再做一些重構","ch20-02-multithreaded.html#將單一執行緒伺服器轉換為多執行緒伺服器","ch20-02-multithreaded.html#對目前伺服器實作模擬緩慢的請求","ch20-02-multithreaded.html#透過執行緒池改善吞吐量","ch20-03-graceful-shutdown-and-cleanup.html#正常關機與清理","ch20-03-graceful-shutdown-and-cleanup.html#對-threadpool-實作-drop-特徵","ch20-03-graceful-shutdown-and-cleanup.html#對執行緒發送停止接收任務的信號","ch20-03-graceful-shutdown-and-cleanup.html#總結","appendix-00.html#附錄","appendix-01-keywords.html#附錄-a關鍵字","appendix-01-keywords.html#目前有在使用的關鍵字","appendix-01-keywords.html#未來可能會使用而保留的關鍵字","appendix-01-keywords.html#原始標識符","appendix-02-operators.html#附錄-b運算子與符號","appendix-02-operators.html#運算子","appendix-02-operators.html#非運算子符號","appendix-03-derivable-traits.html#附錄-c可推導的特徵","appendix-03-derivable-traits.html#用於開發時輸出的-debug","appendix-03-derivable-traits.html#用於比較相等的-partialeq-與-eq","appendix-03-derivable-traits.html#用於比較順序的-partialord-與-ord","appendix-03-derivable-traits.html#用於複製數值的-clone-與-copy","appendix-03-derivable-traits.html#用於映射數值至固定大小數值的-hash","appendix-03-derivable-traits.html#用於預設數值的-default","appendix-04-useful-development-tools.html#附錄-d---實用開發工具","appendix-04-useful-development-tools.html#透過-rustfmt-自動格式化","appendix-04-useful-development-tools.html#透過-rustfix-修正你的程式碼","appendix-04-useful-development-tools.html#透過-clippy-運用更多功能","appendix-04-useful-development-tools.html#使用-rust-analyzer-整合-ide","appendix-05-editions.html#附錄-e---版號","appendix-06-translation.html#附錄-f本書的翻譯本","appendix-07-nightly-rust.html#附錄-g---rust-的開發流程與每夜版-rust","appendix-07-nightly-rust.html#無停滯穩定","appendix-07-nightly-rust.html#嘟嘟火車出發發佈通道與時刻表","appendix-07-nightly-rust.html#不穩定功能","appendix-07-nightly-rust.html#rustup-與-rust-每夜版的職責","appendix-07-nightly-rust.html#rfc-流程與團隊","appendix-08-terminology.html#中英術語對照表","appendix-08-terminology.html#未翻譯"],"index":{"documentStore":{"docInfo":{"0":{"body":31,"breadcrumbs":2,"title":1},"1":{"body":18,"breadcrumbs":0,"title":0},"10":{"body":35,"breadcrumbs":0,"title":0},"100":{"body":226,"breadcrumbs":0,"title":0},"101":{"body":151,"breadcrumbs":1,"title":1},"102":{"body":70,"breadcrumbs":2,"title":1},"103":{"body":76,"breadcrumbs":1,"title":0},"104":{"body":114,"breadcrumbs":2,"title":1},"105":{"body":88,"breadcrumbs":1,"title":0},"106":{"body":78,"breadcrumbs":3,"title":2},"107":{"body":109,"breadcrumbs":0,"title":0},"108":{"body":6,"breadcrumbs":0,"title":0},"109":{"body":14,"breadcrumbs":2,"title":1},"11":{"body":1,"breadcrumbs":0,"title":0},"110":{"body":80,"breadcrumbs":3,"title":1},"111":{"body":4,"breadcrumbs":1,"title":0},"112":{"body":80,"breadcrumbs":1,"title":0},"113":{"body":74,"breadcrumbs":1,"title":0},"114":{"body":138,"breadcrumbs":1,"title":0},"115":{"body":177,"breadcrumbs":2,"title":1},"116":{"body":34,"breadcrumbs":2,"title":1},"117":{"body":91,"breadcrumbs":1,"title":0},"118":{"body":124,"breadcrumbs":3,"title":1},"119":{"body":84,"breadcrumbs":3,"title":1},"12":{"body":8,"breadcrumbs":0,"title":0},"120":{"body":32,"breadcrumbs":2,"title":0},"121":{"body":46,"breadcrumbs":4,"title":2},"122":{"body":53,"breadcrumbs":2,"title":0},"123":{"body":103,"breadcrumbs":3,"title":1},"124":{"body":6,"breadcrumbs":2,"title":0},"125":{"body":68,"breadcrumbs":1,"title":0},"126":{"body":20,"breadcrumbs":1,"title":0},"127":{"body":5,"breadcrumbs":1,"title":0},"128":{"body":8,"breadcrumbs":0,"title":0},"129":{"body":1,"breadcrumbs":0,"title":0},"13":{"body":11,"breadcrumbs":0,"title":0},"130":{"body":38,"breadcrumbs":0,"title":0},"131":{"body":19,"breadcrumbs":0,"title":0},"132":{"body":121,"breadcrumbs":0,"title":0},"133":{"body":34,"breadcrumbs":0,"title":0},"134":{"body":25,"breadcrumbs":0,"title":0},"135":{"body":15,"breadcrumbs":0,"title":0},"136":{"body":6,"breadcrumbs":4,"title":2},"137":{"body":21,"breadcrumbs":2,"title":0},"138":{"body":81,"breadcrumbs":2,"title":0},"139":{"body":166,"breadcrumbs":2,"title":0},"14":{"body":1,"breadcrumbs":0,"title":0},"140":{"body":194,"breadcrumbs":2,"title":0},"141":{"body":43,"breadcrumbs":2,"title":0},"142":{"body":19,"breadcrumbs":2,"title":0},"143":{"body":11,"breadcrumbs":2,"title":0},"144":{"body":16,"breadcrumbs":0,"title":0},"145":{"body":25,"breadcrumbs":0,"title":0},"146":{"body":42,"breadcrumbs":0,"title":0},"147":{"body":26,"breadcrumbs":0,"title":0},"148":{"body":94,"breadcrumbs":0,"title":0},"149":{"body":16,"breadcrumbs":0,"title":0},"15":{"body":32,"breadcrumbs":3,"title":3},"150":{"body":5,"breadcrumbs":0,"title":0},"151":{"body":11,"breadcrumbs":0,"title":0},"152":{"body":3,"breadcrumbs":2,"title":1},"153":{"body":52,"breadcrumbs":1,"title":0},"154":{"body":136,"breadcrumbs":3,"title":2},"155":{"body":125,"breadcrumbs":2,"title":1},"156":{"body":57,"breadcrumbs":1,"title":0},"157":{"body":26,"breadcrumbs":4,"title":3},"158":{"body":79,"breadcrumbs":3,"title":2},"159":{"body":408,"breadcrumbs":1,"title":0},"16":{"body":25,"breadcrumbs":2,"title":2},"160":{"body":7,"breadcrumbs":4,"title":2},"161":{"body":6,"breadcrumbs":2,"title":0},"162":{"body":33,"breadcrumbs":2,"title":0},"163":{"body":11,"breadcrumbs":2,"title":0},"164":{"body":140,"breadcrumbs":2,"title":0},"165":{"body":8,"breadcrumbs":2,"title":0},"166":{"body":11,"breadcrumbs":0,"title":0},"167":{"body":138,"breadcrumbs":0,"title":0},"168":{"body":0,"breadcrumbs":0,"title":0},"169":{"body":179,"breadcrumbs":0,"title":0},"17":{"body":25,"breadcrumbs":0,"title":0},"170":{"body":147,"breadcrumbs":0,"title":0},"171":{"body":33,"breadcrumbs":0,"title":0},"172":{"body":193,"breadcrumbs":0,"title":0},"173":{"body":35,"breadcrumbs":0,"title":0},"174":{"body":3,"breadcrumbs":0,"title":0},"175":{"body":30,"breadcrumbs":0,"title":0},"176":{"body":142,"breadcrumbs":0,"title":0},"177":{"body":210,"breadcrumbs":0,"title":0},"178":{"body":172,"breadcrumbs":0,"title":0},"179":{"body":192,"breadcrumbs":0,"title":0},"18":{"body":11,"breadcrumbs":0,"title":0},"180":{"body":70,"breadcrumbs":0,"title":0},"181":{"body":1,"breadcrumbs":0,"title":0},"182":{"body":84,"breadcrumbs":0,"title":0},"183":{"body":51,"breadcrumbs":0,"title":0},"184":{"body":119,"breadcrumbs":0,"title":0},"185":{"body":10,"breadcrumbs":0,"title":0},"186":{"body":175,"breadcrumbs":0,"title":0},"187":{"body":85,"breadcrumbs":0,"title":0},"188":{"body":34,"breadcrumbs":0,"title":0},"189":{"body":107,"breadcrumbs":0,"title":0},"19":{"body":3,"breadcrumbs":0,"title":0},"190":{"body":75,"breadcrumbs":0,"title":0},"191":{"body":10,"breadcrumbs":0,"title":0},"192":{"body":43,"breadcrumbs":0,"title":0},"193":{"body":3,"breadcrumbs":0,"title":0},"194":{"body":14,"breadcrumbs":0,"title":0},"195":{"body":5,"breadcrumbs":0,"title":0},"196":{"body":325,"breadcrumbs":0,"title":0},"197":{"body":414,"breadcrumbs":1,"title":1},"198":{"body":221,"breadcrumbs":3,"title":3},"199":{"body":189,"breadcrumbs":0,"title":0},"2":{"body":9,"breadcrumbs":0,"title":0},"20":{"body":13,"breadcrumbs":4,"title":2},"200":{"body":375,"breadcrumbs":1,"title":1},"201":{"body":39,"breadcrumbs":2,"title":2},"202":{"body":18,"breadcrumbs":0,"title":0},"203":{"body":8,"breadcrumbs":0,"title":0},"204":{"body":207,"breadcrumbs":0,"title":0},"205":{"body":198,"breadcrumbs":0,"title":0},"206":{"body":158,"breadcrumbs":0,"title":0},"207":{"body":2,"breadcrumbs":0,"title":0},"208":{"body":73,"breadcrumbs":0,"title":0},"209":{"body":372,"breadcrumbs":0,"title":0},"21":{"body":29,"breadcrumbs":2,"title":0},"210":{"body":3,"breadcrumbs":0,"title":0},"211":{"body":19,"breadcrumbs":2,"title":1},"212":{"body":25,"breadcrumbs":1,"title":0},"213":{"body":29,"breadcrumbs":1,"title":0},"214":{"body":59,"breadcrumbs":3,"title":2},"215":{"body":46,"breadcrumbs":1,"title":0},"216":{"body":106,"breadcrumbs":1,"title":0},"217":{"body":11,"breadcrumbs":1,"title":0},"218":{"body":137,"breadcrumbs":1,"title":0},"219":{"body":88,"breadcrumbs":2,"title":1},"22":{"body":38,"breadcrumbs":3,"title":1},"220":{"body":313,"breadcrumbs":1,"title":0},"221":{"body":302,"breadcrumbs":2,"title":1},"222":{"body":116,"breadcrumbs":2,"title":1},"223":{"body":7,"breadcrumbs":1,"title":0},"224":{"body":312,"breadcrumbs":1,"title":0},"225":{"body":513,"breadcrumbs":1,"title":0},"226":{"body":1,"breadcrumbs":1,"title":0},"227":{"body":128,"breadcrumbs":2,"title":1},"228":{"body":750,"breadcrumbs":2,"title":1},"229":{"body":8,"breadcrumbs":1,"title":0},"23":{"body":29,"breadcrumbs":3,"title":1},"230":{"body":8,"breadcrumbs":1,"title":0},"231":{"body":42,"breadcrumbs":1,"title":0},"232":{"body":4,"breadcrumbs":1,"title":0},"233":{"body":8,"breadcrumbs":0,"title":0},"234":{"body":1,"breadcrumbs":0,"title":0},"235":{"body":127,"breadcrumbs":0,"title":0},"236":{"body":145,"breadcrumbs":0,"title":0},"237":{"body":141,"breadcrumbs":0,"title":0},"238":{"body":301,"breadcrumbs":1,"title":1},"239":{"body":37,"breadcrumbs":0,"title":0},"24":{"body":61,"breadcrumbs":2,"title":0},"240":{"body":64,"breadcrumbs":2,"title":2},"241":{"body":38,"breadcrumbs":0,"title":0},"242":{"body":92,"breadcrumbs":0,"title":0},"243":{"body":80,"breadcrumbs":0,"title":0},"244":{"body":3,"breadcrumbs":2,"title":1},"245":{"body":569,"breadcrumbs":2,"title":1},"246":{"body":260,"breadcrumbs":1,"title":0},"247":{"body":5,"breadcrumbs":1,"title":0},"248":{"body":77,"breadcrumbs":2,"title":1},"249":{"body":5,"breadcrumbs":1,"title":0},"25":{"body":22,"breadcrumbs":4,"title":2},"250":{"body":5,"breadcrumbs":4,"title":2},"251":{"body":79,"breadcrumbs":2,"title":0},"252":{"body":4,"breadcrumbs":6,"title":2},"253":{"body":164,"breadcrumbs":4,"title":0},"254":{"body":270,"breadcrumbs":7,"title":3},"255":{"body":25,"breadcrumbs":5,"title":1},"256":{"body":119,"breadcrumbs":5,"title":1},"257":{"body":42,"breadcrumbs":5,"title":1},"258":{"body":5,"breadcrumbs":5,"title":1},"259":{"body":35,"breadcrumbs":7,"title":3},"26":{"body":99,"breadcrumbs":3,"title":1},"260":{"body":5,"breadcrumbs":4,"title":1},"261":{"body":59,"breadcrumbs":3,"title":0},"262":{"body":436,"breadcrumbs":3,"title":0},"263":{"body":66,"breadcrumbs":6,"title":2},"264":{"body":14,"breadcrumbs":4,"title":1},"265":{"body":6,"breadcrumbs":3,"title":0},"266":{"body":23,"breadcrumbs":0,"title":0},"267":{"body":7,"breadcrumbs":2,"title":1},"268":{"body":28,"breadcrumbs":2,"title":1},"269":{"body":294,"breadcrumbs":2,"title":1},"27":{"body":118,"breadcrumbs":3,"title":1},"270":{"body":12,"breadcrumbs":2,"title":1},"271":{"body":99,"breadcrumbs":1,"title":0},"272":{"body":33,"breadcrumbs":2,"title":1},"273":{"body":96,"breadcrumbs":1,"title":0},"274":{"body":77,"breadcrumbs":2,"title":1},"275":{"body":146,"breadcrumbs":1,"title":0},"276":{"body":25,"breadcrumbs":1,"title":0},"277":{"body":90,"breadcrumbs":2,"title":1},"278":{"body":168,"breadcrumbs":2,"title":1},"279":{"body":8,"breadcrumbs":2,"title":1},"28":{"body":11,"breadcrumbs":3,"title":1},"280":{"body":172,"breadcrumbs":2,"title":1},"281":{"body":92,"breadcrumbs":2,"title":1},"282":{"body":8,"breadcrumbs":2,"title":1},"283":{"body":28,"breadcrumbs":2,"title":1},"284":{"body":674,"breadcrumbs":1,"title":0},"285":{"body":124,"breadcrumbs":3,"title":2},"286":{"body":13,"breadcrumbs":0,"title":0},"287":{"body":205,"breadcrumbs":0,"title":0},"288":{"body":394,"breadcrumbs":2,"title":2},"289":{"body":8,"breadcrumbs":0,"title":0},"29":{"body":14,"breadcrumbs":3,"title":1},"290":{"body":18,"breadcrumbs":0,"title":0},"291":{"body":10,"breadcrumbs":0,"title":0},"292":{"body":32,"breadcrumbs":1,"title":1},"293":{"body":83,"breadcrumbs":1,"title":1},"294":{"body":260,"breadcrumbs":1,"title":1},"295":{"body":93,"breadcrumbs":0,"title":0},"296":{"body":101,"breadcrumbs":0,"title":0},"297":{"body":41,"breadcrumbs":0,"title":0},"298":{"body":53,"breadcrumbs":0,"title":0},"299":{"body":1,"breadcrumbs":0,"title":0},"3":{"body":1,"breadcrumbs":1,"title":1},"30":{"body":10,"breadcrumbs":2,"title":0},"300":{"body":349,"breadcrumbs":0,"title":0},"301":{"body":19,"breadcrumbs":2,"title":2},"302":{"body":4,"breadcrumbs":4,"title":2},"303":{"body":23,"breadcrumbs":3,"title":1},"304":{"body":22,"breadcrumbs":3,"title":1},"305":{"body":9,"breadcrumbs":4,"title":2},"306":{"body":11,"breadcrumbs":2,"title":0},"307":{"body":12,"breadcrumbs":2,"title":1},"308":{"body":1,"breadcrumbs":1,"title":0},"309":{"body":23,"breadcrumbs":1,"title":0},"31":{"body":6,"breadcrumbs":0,"title":0},"310":{"body":107,"breadcrumbs":1,"title":0},"311":{"body":11,"breadcrumbs":1,"title":0},"312":{"body":8,"breadcrumbs":1,"title":0},"313":{"body":30,"breadcrumbs":1,"title":0},"314":{"body":116,"breadcrumbs":1,"title":0},"315":{"body":237,"breadcrumbs":1,"title":0},"316":{"body":7,"breadcrumbs":1,"title":0},"317":{"body":37,"breadcrumbs":1,"title":0},"318":{"body":62,"breadcrumbs":2,"title":1},"319":{"body":60,"breadcrumbs":1,"title":0},"32":{"body":57,"breadcrumbs":0,"title":0},"320":{"body":51,"breadcrumbs":1,"title":0},"321":{"body":131,"breadcrumbs":1,"title":0},"322":{"body":436,"breadcrumbs":3,"title":2},"323":{"body":247,"breadcrumbs":1,"title":0},"324":{"body":5,"breadcrumbs":1,"title":0},"325":{"body":9,"breadcrumbs":0,"title":0},"326":{"body":1,"breadcrumbs":0,"title":0},"327":{"body":30,"breadcrumbs":1,"title":1},"328":{"body":52,"breadcrumbs":0,"title":0},"329":{"body":25,"breadcrumbs":0,"title":0},"33":{"body":78,"breadcrumbs":0,"title":0},"330":{"body":47,"breadcrumbs":0,"title":0},"331":{"body":103,"breadcrumbs":0,"title":0},"332":{"body":42,"breadcrumbs":0,"title":0},"333":{"body":172,"breadcrumbs":0,"title":0},"334":{"body":0,"breadcrumbs":0,"title":0},"335":{"body":15,"breadcrumbs":0,"title":0},"336":{"body":71,"breadcrumbs":0,"title":0},"337":{"body":16,"breadcrumbs":0,"title":0},"338":{"body":41,"breadcrumbs":0,"title":0},"339":{"body":292,"breadcrumbs":0,"title":0},"34":{"body":50,"breadcrumbs":0,"title":0},"340":{"body":255,"breadcrumbs":0,"title":0},"341":{"body":139,"breadcrumbs":0,"title":0},"342":{"body":47,"breadcrumbs":0,"title":0},"343":{"body":4,"breadcrumbs":0,"title":0},"344":{"body":16,"breadcrumbs":0,"title":0},"345":{"body":12,"breadcrumbs":2,"title":1},"346":{"body":22,"breadcrumbs":1,"title":0},"347":{"body":78,"breadcrumbs":1,"title":0},"348":{"body":379,"breadcrumbs":1,"title":0},"349":{"body":54,"breadcrumbs":1,"title":0},"35":{"body":40,"breadcrumbs":0,"title":0},"350":{"body":32,"breadcrumbs":1,"title":0},"351":{"body":7,"breadcrumbs":1,"title":0},"352":{"body":4,"breadcrumbs":1,"title":0},"353":{"body":1,"breadcrumbs":0,"title":0},"354":{"body":91,"breadcrumbs":0,"title":0},"355":{"body":147,"breadcrumbs":0,"title":0},"356":{"body":406,"breadcrumbs":0,"title":0},"357":{"body":238,"breadcrumbs":0,"title":0},"358":{"body":69,"breadcrumbs":0,"title":0},"359":{"body":4,"breadcrumbs":0,"title":0},"36":{"body":82,"breadcrumbs":1,"title":1},"360":{"body":17,"breadcrumbs":0,"title":0},"361":{"body":229,"breadcrumbs":0,"title":0},"362":{"body":134,"breadcrumbs":0,"title":0},"363":{"body":66,"breadcrumbs":1,"title":1},"364":{"body":0,"breadcrumbs":0,"title":0},"365":{"body":107,"breadcrumbs":0,"title":0},"366":{"body":92,"breadcrumbs":0,"title":0},"367":{"body":7,"breadcrumbs":0,"title":0},"368":{"body":9,"breadcrumbs":0,"title":0},"369":{"body":76,"breadcrumbs":1,"title":1},"37":{"body":31,"breadcrumbs":1,"title":1},"370":{"body":25,"breadcrumbs":0,"title":0},"371":{"body":339,"breadcrumbs":1,"title":1},"372":{"body":23,"breadcrumbs":0,"title":0},"373":{"body":21,"breadcrumbs":0,"title":0},"374":{"body":1,"breadcrumbs":0,"title":0},"375":{"body":18,"breadcrumbs":0,"title":0},"376":{"body":17,"breadcrumbs":0,"title":0},"377":{"body":72,"breadcrumbs":1,"title":1},"378":{"body":137,"breadcrumbs":0,"title":0},"379":{"body":45,"breadcrumbs":1,"title":1},"38":{"body":18,"breadcrumbs":0,"title":0},"380":{"body":79,"breadcrumbs":0,"title":0},"381":{"body":100,"breadcrumbs":1,"title":1},"382":{"body":172,"breadcrumbs":0,"title":0},"383":{"body":61,"breadcrumbs":0,"title":0},"384":{"body":0,"breadcrumbs":0,"title":0},"385":{"body":83,"breadcrumbs":0,"title":0},"386":{"body":1490,"breadcrumbs":0,"title":0},"387":{"body":8,"breadcrumbs":0,"title":0},"388":{"body":632,"breadcrumbs":2,"title":2},"389":{"body":641,"breadcrumbs":0,"title":0},"39":{"body":6,"breadcrumbs":0,"title":0},"390":{"body":4,"breadcrumbs":0,"title":0},"391":{"body":1,"breadcrumbs":0,"title":0},"392":{"body":1,"breadcrumbs":0,"title":0},"393":{"body":42,"breadcrumbs":0,"title":0},"394":{"body":13,"breadcrumbs":0,"title":0},"395":{"body":57,"breadcrumbs":0,"title":0},"396":{"body":1,"breadcrumbs":2,"title":1},"397":{"body":152,"breadcrumbs":1,"title":0},"398":{"body":142,"breadcrumbs":1,"title":0},"399":{"body":12,"breadcrumbs":2,"title":1},"4":{"body":11,"breadcrumbs":0,"title":0},"40":{"body":210,"breadcrumbs":1,"title":1},"400":{"body":4,"breadcrumbs":2,"title":1},"401":{"body":16,"breadcrumbs":3,"title":2},"402":{"body":33,"breadcrumbs":3,"title":2},"403":{"body":32,"breadcrumbs":3,"title":2},"404":{"body":10,"breadcrumbs":2,"title":1},"405":{"body":17,"breadcrumbs":2,"title":1},"406":{"body":2,"breadcrumbs":2,"title":1},"407":{"body":20,"breadcrumbs":2,"title":1},"408":{"body":74,"breadcrumbs":2,"title":1},"409":{"body":71,"breadcrumbs":2,"title":1},"41":{"body":83,"breadcrumbs":0,"title":0},"410":{"body":21,"breadcrumbs":4,"title":3},"411":{"body":40,"breadcrumbs":2,"title":1},"412":{"body":18,"breadcrumbs":2,"title":1},"413":{"body":2,"breadcrumbs":6,"title":3},"414":{"body":5,"breadcrumbs":3,"title":0},"415":{"body":63,"breadcrumbs":3,"title":0},"416":{"body":3,"breadcrumbs":3,"title":0},"417":{"body":49,"breadcrumbs":5,"title":2},"418":{"body":15,"breadcrumbs":4,"title":1},"419":{"body":192,"breadcrumbs":1,"title":0},"42":{"body":257,"breadcrumbs":0,"title":0},"420":{"body":18,"breadcrumbs":1,"title":0},"43":{"body":75,"breadcrumbs":0,"title":0},"44":{"body":38,"breadcrumbs":0,"title":0},"45":{"body":140,"breadcrumbs":0,"title":0},"46":{"body":6,"breadcrumbs":0,"title":0},"47":{"body":9,"breadcrumbs":0,"title":0},"48":{"body":116,"breadcrumbs":0,"title":0},"49":{"body":18,"breadcrumbs":0,"title":0},"5":{"body":2,"breadcrumbs":0,"title":0},"50":{"body":101,"breadcrumbs":1,"title":1},"51":{"body":47,"breadcrumbs":0,"title":0},"52":{"body":178,"breadcrumbs":0,"title":0},"53":{"body":154,"breadcrumbs":0,"title":0},"54":{"body":44,"breadcrumbs":0,"title":0},"55":{"body":79,"breadcrumbs":0,"title":0},"56":{"body":160,"breadcrumbs":0,"title":0},"57":{"body":120,"breadcrumbs":0,"title":0},"58":{"body":17,"breadcrumbs":0,"title":0},"59":{"body":3,"breadcrumbs":0,"title":0},"6":{"body":3,"breadcrumbs":0,"title":0},"60":{"body":231,"breadcrumbs":0,"title":0},"61":{"body":245,"breadcrumbs":0,"title":0},"62":{"body":6,"breadcrumbs":0,"title":0},"63":{"body":6,"breadcrumbs":0,"title":0},"64":{"body":3,"breadcrumbs":0,"title":0},"65":{"body":14,"breadcrumbs":1,"title":1},"66":{"body":2,"breadcrumbs":0,"title":0},"67":{"body":23,"breadcrumbs":0,"title":0},"68":{"body":25,"breadcrumbs":1,"title":1},"69":{"body":262,"breadcrumbs":0,"title":0},"7":{"body":3,"breadcrumbs":0,"title":0},"70":{"body":44,"breadcrumbs":0,"title":0},"71":{"body":71,"breadcrumbs":0,"title":0},"72":{"body":136,"breadcrumbs":0,"title":0},"73":{"body":221,"breadcrumbs":0,"title":0},"74":{"body":108,"breadcrumbs":0,"title":0},"75":{"body":0,"breadcrumbs":0,"title":0},"76":{"body":143,"breadcrumbs":0,"title":0},"77":{"body":274,"breadcrumbs":0,"title":0},"78":{"body":15,"breadcrumbs":0,"title":0},"79":{"body":4,"breadcrumbs":0,"title":0},"8":{"body":9,"breadcrumbs":0,"title":0},"80":{"body":5,"breadcrumbs":0,"title":0},"81":{"body":131,"breadcrumbs":0,"title":0},"82":{"body":54,"breadcrumbs":0,"title":0},"83":{"body":109,"breadcrumbs":0,"title":0},"84":{"body":30,"breadcrumbs":0,"title":0},"85":{"body":15,"breadcrumbs":0,"title":0},"86":{"body":108,"breadcrumbs":0,"title":0},"87":{"body":64,"breadcrumbs":0,"title":0},"88":{"body":22,"breadcrumbs":0,"title":0},"89":{"body":50,"breadcrumbs":0,"title":0},"9":{"body":0,"breadcrumbs":0,"title":0},"90":{"body":230,"breadcrumbs":0,"title":0},"91":{"body":3,"breadcrumbs":0,"title":0},"92":{"body":122,"breadcrumbs":0,"title":0},"93":{"body":57,"breadcrumbs":0,"title":0},"94":{"body":128,"breadcrumbs":0,"title":0},"95":{"body":38,"breadcrumbs":0,"title":0},"96":{"body":63,"breadcrumbs":1,"title":1},"97":{"body":2,"breadcrumbs":0,"title":0},"98":{"body":3,"breadcrumbs":0,"title":0},"99":{"body":35,"breadcrumbs":0,"title":0}},"docs":{"0":{"body":"由 Steve Klabnik 與 Carol Nichols,以及 Rust 社群的貢獻撰寫而成 此版本假設你使用的是 Rust 1.65(於 2022-11-03 發布)或更高的版本,並在所有專案中的 Cargo.toml 都有 edition=\"2021\" 來使用 Rust 2021 版號。請查看 第一章的「安裝」段落 來安裝或更新 Rust。 本書的 HTML 格式可以在線上閱讀: https://doc.rust-lang.org/stable/book/ ( 正體中文版 )。而離線版則包含在 rustup 安裝的 Rust 中,輸入 rustup docs --book 就能開啟。 社群中也有提供本書的各種[譯本]。 本書也有由 No Starch Press 出版平裝與電子版格式 。 🚨 想要更有互動的學習體驗?來嘗試不同的 Rust Book,賣點有:隨堂測驗、重點提示、視覺化呈現,更多都在 https://rust-book.cs.brown.edu commit: 3f64052","breadcrumbs":"Rust 程式設計語言 » Rust 程式設計語言","id":"0","title":"Rust 程式設計語言"},"1":{"body":"雖然不是那麼明確,但 Rust 程式設計語言旨在 賦權(empowerment) :無論你現在寫的是何種程式碼,Rust 都能賦予你更多能力,在更廣泛的領域中帶有自信地向前邁進。 比方說,「系統層級」的工作會需要處理低階的記憶體管理、資料呈現與程序並行的細節。對以往來說,這塊程式領域被視為巫術般的存在,只有投入好幾年時間學習的選中之人才有辦法駕馭,也才能懂得如何避開其惡名昭彰的陷阱。而且就算是這個領域的實作者也謹慎行事,也生怕他們的程式碼會出現漏洞、崩潰或損壞。 Rust 破除了這些障礙,消除了以往的陷阱並提供友善全面的工具來協助你。想要「深入」底層控制的程式設計師可以使用 Rust,無需冒著常見的崩潰或安全漏洞風險,也無需學習得經常改變的工具鏈其中的細節。更好地是,這個語言本身就是設計成能引導你自然而然地寫出可靠且在速度與記憶體使用都十分高效的程式碼。 已經在處理底層程式碼的程式設計師可以使用 Rust 來擴展他們的野心。舉例來說,在 Rust 中進行平行化是相對低風險的動作,編譯器會幫你抓到典型的錯誤。而且你也能更有自信且更積極地進行最佳化,不必擔心會意外造成崩潰或漏洞。 但 Rust 並不只限於底層的系統程式設計。其表現力與易用易讀的程度能令人愉快地寫出 CLI 應用程式、網頁伺服器與許多其他種程式碼。你會在本書中看到這兩種簡單的範例。使用 Rust 能這讓你將一個領域所學到的技能延伸到另一個領域,你可以透過寫網頁應用程式來學習 Rust,然後應用同樣的技能到你的樹莓派(Raspberry Pi)上。 本書充分體現了 Rust 賦予其使用者更多能力的潛力。其內容平易近人,不止致力於協助你提升 Rust 的知識,還能提升讓你身為程式設計師的整體信心。所以讓我們準備開始學習吧,歡迎加入 Rust 的社群! — Nicholas Matsakis 與 Aaron Turon","breadcrumbs":"前言 » 前言","id":"1","title":"前言"},"10":{"body":"一般來說,本書預設你會從前往後依序閱讀。後面的章節建立在前面提到的概念上,並且前面的章節不會深入某特定主題,而於後面的章節再議。 你會發現本書有兩種類型的章節:概念章節與專案章節。在概念章節中,你會學到 Rust 的某些概念。在專案章節中,我們會一起應用當前所學來做小專案。第二、十二和二十章是專案章節,其餘是概念章節。 第一章會解釋如何安裝 Rust、如何寫支「Hello, world!」程式以及如何使用 Cargo--Rust 的套件管理與建構工具。第二章透過實作一款猜數字遊戲的程式來介紹 Rust。我們在此提及大概的觀念,並在之後的章節提供更詳細的介紹。如果你想馬上動手實作看看的話,第二章會很適合你。第三章會涵蓋 Rust 與其他程式設計語言類似的功能。第四章則會學習 Rust 的所有權系統。如果你是嚴謹派的讀者、傾向先學習所有細節再進入實作,你可能會想跳過第二章直接前往第三章。當你想要應用學到的細節時,再回到第二章練習。 第五章討論結構體與方法,而第六章涵蓋列舉、match 表達式與 if let 控制流程的語法。你會在 Rust 中用結構體與列舉來自訂型別。 在第七章中,你會學到 Rust 的模組系統與隱私規則,讓你可以組織程式碼以及其公開應用程式介面(Application Programming Interface, API)。第八章會討論標準函式庫提供的一些常見集合資料結構,像是向量、字串與雜湊映射。第九章會探討 Rust 的錯誤處理哲學與技巧。 第十章將深入探討泛型、特徵(traits)與生命週期,讓你能定義出能套用多種型別的程式碼。第十一章都在討論測試,就算有 Rust 的安全性保障,還是必須透過測試來確保你的程式邏輯正確。在第十二章中,我們會動手實作 grep 命令列工具的部分功能,可以搜尋檔案中的文字。我們將會應用前幾章討論過的許多概念。 第十三章會探索閉包與疊代器,這是 Rust 借鑒函式程式設計語言的功能。在第十四章中,我們要更深入研究 Cargo 並討論分享函式庫給其他人的最佳方式。第十五章會討論標準函式庫提供的智慧指標以及能啟用它們功能的特徵(traits)。 在第十六章中,我們會介紹各種不同的並行程式設計模型,並談論 Rust 如何幫助你無懼地開發多執行緒的程式。第十七章會拿 Rust 的慣用風格與你可能較熟悉的物件導向程式設計原則作比較。 第十八章涉及模式與模式配對,它們的強大力量讓你能用 Rust 表達更多概念。第十九章是進階主題的大雜燴,其中包含:不安全(unsafe)的 Rust、巨集、以及更多關於生命週期、特徵、型別、函式與閉包的介紹。 在第二十章中,我們會完整實作一個底層跑多執行緒的網頁伺服器! 最後,以參照的方式收錄本語言的一些實用資訊。附錄 A 涵蓋 Rust 的關鍵字、附錄 B 涵蓋 Rust 的運算子與符號、附錄 C 涵蓋標準函式庫提供的可推導的特徵(derivable traits)、附錄 D 涵蓋一些實用開發工具,然後附錄 E 會解釋 Rust 的版號。在附錄 F 中你可以找到本書籍的各種翻譯版本,然後在附錄 G 我們會講解 Rust 的開發流程以及什麼是每夜版(Nightly)Rust。 本書沒有錯誤的閱讀方式--如果你想要跳過一些章節,儘管跳過吧!後面也許會遇到不懂的地方而需要回頭去看。總之用最適合自己的方式閱讀。 學習 Rust 的過程中有個重要的部分--學習如何閱讀編譯器顯示的錯誤訊息,讓訊息引導你寫出正確的程式碼。因此,我們特意提供很多無法編譯的範例,以及編譯器對應顯示的錯誤訊息。如果你隨意挑一則範例執行的話,它可能無法編譯喔!請務必看看範例旁的文字來瞭解該範例是不是故意出錯。可愛的吉祥物 Ferris 也能幫助你分辨哪些程式碼本來就無法運作: Ferris 意思 此程式碼無法編譯! 此程式碼會恐慌! 此程式碼不會產生預期的行為。 在大多數的情況下,我們會引導你將無法編譯的程式碼寫成正確的版本。","breadcrumbs":"介紹 » 如何閱讀本書","id":"10","title":"如何閱讀本書"},"100":{"body":"我們可以像這樣建立兩個不同變體的 IpAddrKind 實例: # enum IpAddrKind {\n# V4,\n# V6,\n# }\n# # fn main() { let four = IpAddrKind::V4; let six = IpAddrKind::V6;\n# # route(IpAddrKind::V4);\n# route(IpAddrKind::V6);\n# }\n# # fn route(ip_kind: IpAddrKind) {} 注意變體會位於列舉命名空間底下,所以我們用兩個冒號來標示。這樣的好處在於 IpAddrKind::V4 和 IpAddrKind::V6 都是同型別 IpAddrKind。比方說,我們就可以定義一個接收任 IpAddrKind 的函式: # enum IpAddrKind {\n# V4,\n# V6,\n# }\n# # fn main() {\n# let four = IpAddrKind::V4;\n# let six = IpAddrKind::V6;\n# # route(IpAddrKind::V4);\n# route(IpAddrKind::V6);\n# }\n# fn route(ip_kind: IpAddrKind) {} 然後我們可以用任意變體呼叫此函式: # enum IpAddrKind {\n# V4,\n# V6,\n# }\n# # fn main() {\n# let four = IpAddrKind::V4;\n# let six = IpAddrKind::V6;\n# route(IpAddrKind::V4); route(IpAddrKind::V6);\n# }\n# # fn route(ip_kind: IpAddrKind) {} 使用列舉還有更多好處。我們再進一步想一下我們的 IP 位址型別還沒有辦法儲存實際的 IP 位址 資料 ,我們現在只知道它是哪種 類型 。考慮到你已經學會第五章的結構體,你應該會像範例 6-1 這樣嘗試用結構體解決問題。 # fn main() { enum IpAddrKind { V4, V6, } struct IpAddr { kind: IpAddrKind, address: String, } let home = IpAddr { kind: IpAddrKind::V4, address: String::from(\"127.0.0.1\"), }; let loopback = IpAddr { kind: IpAddrKind::V6, address: String::from(\"::1\"), };\n# } 範例 6-1:使用 struct 儲存 IP 位址的資料與 IpAddrKind 的變體 我們在這裡定義了一個有兩個欄位的結構體 IpAddr:欄位 kind 擁有 IpAddrKind(我們上面定義過的列舉)型別,address 欄位則是 String 型別。再來我們有兩個此結構體的實例。第一個 home 擁有 IpAddrKind::V4 作為 kind 的值,然後位址資料是 127.0.0.1。第二個實例 loopback 擁有 IpAddrKind 另一個變體 V6 作為 kind 的值,且有 ::1 作為位址資料。我們用結構體來組織 kind 和 address 的值在一起,讓變體可以與數值相關。 但是我們可以用另一種更簡潔的方式來定義列舉就好,而不必使用結構體加上列舉。列舉內的每個變體其實都能擁有數值。以下這樣新的定義方式讓 IpAddr 的 V4 與 V6 都能擁有與其相關的 String 數值: # fn main() { enum IpAddr { V4(String), V6(String), } let home = IpAddr::V4(String::from(\"127.0.0.1\")); let loopback = IpAddr::V6(String::from(\"::1\"));\n# } 我們將資料直接附加到列舉的每個變體上,這樣就不再用結構體。這裏我們還能看到另一項列舉的細節:我們定義的每一個列舉變體也會變成建構該列舉的函式。也就是說 IpAddr::V4() 是個函式,且接收 String 引數並回傳 IpAddr 的實例。我們在定義列舉時就會自動拿到這樣的建構函式。 改使用列舉而非結構體的話還有另一項好處:每個變體可以擁有不同型別與資料的數量。第四版的 IP 位址永遠只會有四個 0 到 255 的數字部分,如果我們想要讓 V4 儲存四個 u8,但 V6 位址仍保持 String 不變的話,我們在結構體是無法做到的。列舉可以輕鬆勝任: # fn main() { enum IpAddr { V4(u8, u8, u8, u8), V6(String), } let home = IpAddr::V4(127, 0, 0, 1); let loopback = IpAddr::V6(String::from(\"::1\"));\n# } 我們展示了許多種定義儲存第四版與第六版 IP 位址資料結構的方式,不過需要儲存 IP 位址並編碼成不同類型的案例實在太常見了,所以 標準函式庫已經幫我們定義好了! 讓我們看看標準函式庫是怎麼定義 IpAddr 的:它有和我們一模一樣的列舉變體,不過變體各自儲存的資料是另外兩個不同的結構體,兩個定義的內容均不相同: struct Ipv4Addr { // --省略--\n} struct Ipv6Addr { // --省略--\n} enum IpAddr { V4(Ipv4Addr), V6(Ipv6Addr),\n} 此程式碼展示了你可以將任何資料類型放入列舉的變體中:字串、數字型別、結構體都可以。你甚至可以再包含另一個列舉!另外標準函式庫內的型別常常沒有你想得那麼複雜。 請注意雖然標準函式庫已經有定義 IpAddr,但我們還是可以使用並建立我們自己定義的型別,而且不會產生衝突,因為我們還沒有將標準函式庫的定義匯入到我們的作用域中。我們會在第七章討論如何將型別匯入作用域內。 讓我們再看看範例 6-2 的另一個列舉範例,這次的變體有各式各樣的型別。 enum Message { Quit, Move { x: i32, y: i32 }, Write(String), ChangeColor(i32, i32, i32),\n}\n# # fn main() {} 範例 6-2:Message 列舉的變體各自擁有不同的型別與數值數量 此列舉有四個不同型別的變體: Quit 沒有包含任何資料。 Move 包含了和結構體一樣的名稱欄位。 Write 包含了一個 String。 ChangeColor 包含了三個 i32。 如同範例 6-2 這樣定義列舉變體和定義不同類型的結構體很像,只不過列舉不使用 struct 關鍵字,而且所有的變體都會在 Message 型別底下。以下的結構體可以包含與上方列舉變體定義過的資料: struct QuitMessage; // 類單元結構體\nstruct MoveMessage { x: i32, y: i32,\n}\nstruct WriteMessage(String); // 元組結構體\nstruct ChangeColorMessage(i32, i32, i32); // 元組結構體\n# # fn main() {} 但是如果我們使用不同結構體且各自都有自己的型別的話,我們就無法像範例 6-2 那樣將 Message 視為單一型別,輕鬆在定義函式時接收訊息所有可能的類型。 列舉和結構體還有一個地方很像:如同我們可以對結構體使用 impl 定義方法,我們也可以對列舉定義方法。以下範例顯示我們可以對 Message 列舉定義一個 call 方法: # fn main() {\n# enum Message {\n# Quit,\n# Move { x: i32, y: i32 },\n# Write(String),\n# ChangeColor(i32, i32, i32),\n# }\n# impl Message { fn call(&self) { // 在此定義方法本體 } } let m = Message::Write(String::from(\"hello\")); m.call();\n# } 方法本體使用 self 來取得我們呼叫方法的值。在此例中,我們建立了一個變數 m 並取得 Message::Write(String::from(\"hello\")),而這就會是當我們執行 m.call() 時 call 方法內會用到的 self。 讓我們再看看另一個標準函式庫內非常常見且實用的列舉:Option。","breadcrumbs":"列舉與模式配對 » 定義列舉 » 列舉數值","id":"100","title":"列舉數值"},"101":{"body":"在此段落我們將來研究 Option,這是在標準函式庫中定義的另一種列舉。Option 廣泛運用在許多場合,它能表示一個數值可能有某個東西,或者什麼都沒有。 舉例來說,如果你向一串包含元素的列表索取第一個值,你會拿到數值,但如果你向空列表索取的話,你就什麼都拿不到。在型別系統中表達這樣的概念可以讓編譯器檢查我們是否都處理完我們該處理的情況了。這樣的功能可以防止其他程式語言中極度常見的程式錯誤。 程式語言設計通常要考慮哪些功能是你要的,但同時哪些功能是你不要的也很重要。Rust 沒有像其他許多語言都有空值。 空值 (Null)代表的是沒有任何數值。在有空值的語言,所有變數都有兩種可能:空值或非空值。 而其發明者 Tony Hoare 在他 2009 的演講「空參考:造成數十億損失的錯誤」(“Null References: The Billion Dollar Mistake”)中提到: 我稱它為我十億美元級的錯誤。當時我正在為一門物件導向語言設計第一個全方位的參考型別系統。我當時的目標是透過編譯器自動檢查來確保所有的參考都是安全的。但我無法抗拒去加入空參考的誘惑,因為實作的方式實在太簡單了。這導致了無數的錯誤、漏洞與系統崩潰,在接下來的四十年中造成了大概數十億美金的痛苦與傷害。 空值的問題在於,如果你想在非空值使用空值的話,你會得到某種錯誤。由於空值與非空值的特性無所不在,你會很容易犯下這類型的錯誤。 但有時候能夠表達「空(null)」的概念還是很有用的:空值代表目前的數值因為某些原因而無效或缺少。 所以問題不在於概念本身,而在於如何實作。所以 Rust 並沒有空值,但是它有一個列舉可以表達出這樣的概念,也就是一個值可能是存在或不存在的。此列舉就是 Option,它是在 標準函式庫中這樣定義的 : enum Option { None, Some(T),\n} Option 實在太實用了,所以它早已加進 prelude 中,你不需要特地匯入作用域中。它的變體一樣也被加進 prelude 中,你可以直接使用 Some 和 None 而不必加上 Option:: 的前綴。Option 仍然就只是個列舉, Some(T) 與 None 仍然是Option 型別的變體。 語法是我們還沒介紹到的 Rust 功能。它是個泛型型別參數,我們會在第十章正式介紹泛型(generics)。現在你只需要知道 指的是 Option 列舉中的 Some 變體可以是任意型別。而透過 Option 數值來持有數字型別和字串型別的話,它們最終會換掉 Option 中的 T,成為不同的型別。以下是使用 Option 來包含數字與字串型別的範例: # fn main() { let some_number = Some(5); let some_char = Some('e'); let absent_number: Option = None;\n# } some_number 的型別是 Option,而 some_char 的型別是 Option,兩者是不同的型別。Rust 可以推導出這些型別,因為我們已經在 Some 變體指定數值。至於 absent_number 的話,Rust 需要我們寫出完整的 Option 型別,因為編譯器無法從 None 推導出相對應的 Some 變體會持有哪種型別。我們在這裡告訴 Rust 我們 absent_number 所指的型別為 Option。 當我們有 Some 值時,我們會知道數值是存在的而且就位於 Some 內。當我們有 None 值時,在某種意義上它代表該值是空的,我們沒有有效的數值。所以為何 Option 會比用空值來得好呢? 簡單來說因為 Option 與 T(T 可以是任意型別)是不同的型別,編譯器不會允許我們像一般有效的值那樣來使用 Option。舉例來說,以下範例是無法編譯的,因為這是將 i8 與 Option 相加: # fn main() { let x: i8 = 5; let y: Option = Some(5); let sum = x + y;\n# } 如果我們執行此程式,我們會得到以下錯誤訊息: $ cargo run Compiling enums v0.1.0 (file:///projects/enums)\nerror[E0277]: cannot add `Option` to `i8` --> src/main.rs:5:17 |\n5 | let sum = x + y; | ^ no implementation for `i8 + Option` | = help: the trait `std::ops::Add