Rust 编程语言极简教程 --- 实例学习
安装
$ curl https://sh.rustup.rs -sSf | shinfo: downloading installerWelcome to Rust!This will download and install the official compiler for the Rust programming language, and its package manager, Cargo. ...
Rust 实例学习
Introduction
- Hello World 1.1. Comments 1.2. Formatted print 1.2.1. Debug 1.2.2. Display 1.2.2.1. Testcase: List 1.2.3. Formatting
- Primitives 2.1. Literals and operators 2.2. Tuples 2.3. Arrays and Slices
- Custom Types 3.1. Structures 3.2. Enums 3.2.1. use 3.2.2. C-like 3.2.3. Testcase: linked-list 3.3. constants
- Variable Bindings 4.1. Mutability 4.2. Scope and Shadowing 4.3. Declare first
- Types 5.1. Casting 5.2. Literals 5.3. Inference 5.4. Aliasing
- Conversion 6.1. From and Into 6.2. To and From String
- Expressions
- Flow Control 8.1. if/else 8.2. loop 8.2.1. Nesting and labels 8.2.2. Returning from loops 8.3. while 8.4. for and range 8.5. match 8.5.1. Destructuring 8.5.1.1. tuples 8.5.1.2. enums 8.5.1.3. pointers/ref 8.5.1.4. structs 8.5.2. Guards 8.5.3. Binding 8.6. if let 8.7. while let
- Functions 9.1. Methods 9.2. Closures 9.2.1. Capturing 9.2.2. As input parameters 9.2.3. Type anonymity 9.2.4. Input functions 9.2.5. As output parameters 9.2.6. Examples in std 9.2.6.1. Iterator::any 9.2.6.2. Iterator::find 9.3. Higher Order Functions
- Modules 10.1. Visibility 10.2. Struct visibility 10.3. The use declaration 10.4. super and self 10.5. File hierarchy
- Crates 11.1. Library 11.2. extern crate
- Attributes 12.1. dead_code 12.2. Crates 12.3. cfg 12.3.1. Custom
- Generics 13.1. Functions 13.2. Implementation 13.3. Traits 13.4. Bounds 13.4.1. Testcase: empty bounds 13.5. Multiple bounds 13.6. Where clauses 13.7. New Type Idiom 13.8. Associated items 13.8.1. The Problem 13.8.2. Associated types 13.9. Phantom type parameters 13.9.1. Testcase: unit clarification
- Scoping rules 14.1. RAII 14.2. Ownership and moves 14.2.1. Mutability 14.3. Borrowing 14.3.1. Mutability 14.3.2. Freezing 14.3.3. Aliasing 14.3.4. The ref pattern 14.4. Lifetimes 14.4.1. Explicit annotation 14.4.2. Functions 14.4.3. Methods 14.4.4. Structs 14.4.5. Bounds 14.4.6. Coercion 14.4.7. static 14.4.8. elision
- Traits 15.1. Derive 15.2. Operator Overloading 15.3. Drop 15.4. Iterators 15.5. Clone
- macro_rules! 16.1. Syntax 16.1.1. Designators 16.1.2. Overload 16.1.3. Repeat 16.2. DRY (Don't Repeat Yourself) 16.3. DSL (Domain Specific Languages) 16.4. Variadics
- Error handling 17.1. panic 17.2. Option & unwrap 17.2.1. Combinators: map 17.2.2. Combinators: and_then 17.3. Result 17.3.1. map for Result 17.3.2. aliases for Result 17.3.3. Early returns 17.3.4. Introducing ? 17.4. Multiple error types 17.4.1. Pulling Results out of Options 17.4.2. Defining an error type 17.4.3. Boxing errors 17.4.4. Other uses of ? 17.4.5. Wrapping errors 17.5. Iterating over Results
- Std library types 18.1. Box, stack and heap 18.2. Vectors 18.3. Strings 18.4. Option 18.5. Result 18.5.1. ? 18.6. panic! 18.7. HashMap 18.7.1. Alternate/custom key types 18.7.2. HashSet
- Std misc 19.1. Threads 19.1.1. Testcase: map-reduce 19.2. Channels 19.3. Path 19.4. File I/O 19.4.1. open 19.4.2. create 19.5. Child processes 19.5.1. Pipes 19.5.2. Wait 19.6. Filesystem Operations 19.7. Program arguments 19.7.1. Argument parsing 19.8. Foreign Function Interface
- Meta 20.1. Documentation 20.2. Testing
- Unsafe Operations