Introduction
1.
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
2.
Primitives
2.1.
Literals and operators
2.2.
Tuples
2.3.
Arrays and Slices
3.
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
4.
Variable Bindings
4.1.
Mutability
4.2.
Scope and shadowing
4.3.
Declare first
5.
Casting
5.1.
Literals
5.2.
Inference
5.3.
Alias
6.
Expressions
7.
Flow Control
7.1.
if/else
7.2.
loop
7.2.1.
Nesting and labels
7.3.
while
7.4.
for and range
7.5.
match
7.5.1.
Destructuring
7.5.1.1.
tuples
7.5.1.2.
enums
7.5.1.3.
pointers/ref
7.5.1.4.
structs
7.5.2.
Guards
7.5.3.
Binding
7.6.
if let
7.7.
while let
8.
Functions
8.1.
Methods
8.2.
Closures
8.2.1.
Capturing
8.2.2.
As input parameters
8.2.3.
Type anonymity
8.2.4.
Input functions
8.2.5.
As output parameters
8.2.6.
Examples in `std`
8.2.6.1.
Iterator::any
8.2.6.2.
Iterator::find
8.3.
Higher Order Functions
9.
macro_rules!
9.1.
Designators
9.2.
Overload
9.3.
Repeat
9.4.
DRY (Don't Repeat Yourself)
10.
Modules
10.1.
Visibility
10.2.
Struct visibility
10.3.
The `use` declaration
10.4.
`super` and `self`
10.5.
File hierarchy
11.
Crates
11.1.
Library
11.2.
`extern crate`
12.
Attributes
12.1.
`dead_code`
12.2.
Crates
12.3.
`cfg`
12.3.1.
Custom
13.
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.
Associated items
13.7.1.
The Problem
13.7.2.
Associated types
13.8.
Phantom type parameters
13.8.1.
Testcase: unit conversions
14.
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
15.
Traits
15.1.
Derive
15.2.
Operator Overloading
15.3.
Drop
15.4.
Iterators
15.5.
Clone
16.
Error handling
16.1.
Option & unwrap
16.2.
map
16.3.
More combinators
16.4.
Errors vs Absence
16.5.
map for Result
16.6.
Result as an alias
16.7.
Options with Results
16.7.1.
Errors as strings
16.7.2.
Combining separate combinators
16.7.3.
Enter try!
16.8.
The limits of strings
16.9.
Re-enter try!
16.10.
Re-enabling box
17.
Std library types
17.1.
Box, stack and heap
17.2.
Vectors
17.3.
Strings
17.4.
`Option`
17.5.
`Result`
17.5.1.
`try!`
17.6.
`panic!`
17.7.
HashMap
17.7.1.
Alternate/custom key types
17.7.2.
HashSet
18.
Std misc
18.1.
Threads
18.2.
Channels
18.3.
Path
18.4.
File I/O
18.4.1.
`open`
18.4.2.
`create`
18.5.
Child processes
18.5.1.
Pipes
18.5.2.
Wait
18.6.
Filesystem Operations
18.7.
Program arguments
18.7.1.
Argument parsing
18.8.
Foreign Function Interface
19.
Meta
19.1.
Documentation
19.2.
Testing
20.
Unsafe operations
Published using GitBook
A
A
Serif
Sans
White
Sepia
Night
Twitter
Google
Facebook
Weibo
Instapaper
Rust by Example中文
7.5.1 Destructuring
A
match
block can destructure items in a variety of ways.