mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 07:20:20 +08:00
% -> #
I forgot Rustdoc renders markdown files strangely
This commit is contained in:
parent
3d2370d2c9
commit
da54953597
@ -1,4 +1,4 @@
|
||||
% Associated Types
|
||||
# Associated Types
|
||||
|
||||
Associated types are a powerful part of Rust’s type system. They’re related to
|
||||
the idea of a ‘type family’, in other words, grouping multiple types together. That
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Closures
|
||||
# Closures
|
||||
|
||||
Sometimes it is useful to wrap up a function and _free variables_ for better
|
||||
clarity and reuse. The free variables that can be used come from the
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Conditional Compilation
|
||||
# Conditional Compilation
|
||||
|
||||
Rust has a special attribute, `#[cfg]`, which allows you to compile code
|
||||
based on a flag passed to the compiler. It has two forms:
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Crates and Modules
|
||||
# Crates and Modules
|
||||
|
||||
When a project starts getting large, it’s considered good software
|
||||
engineering practice to split it up into a bunch of smaller pieces, and then
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Enums
|
||||
# Enums
|
||||
|
||||
An `enum` in Rust is a type that represents data that is one of
|
||||
several possible variants. Each variant in the `enum` can optionally
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Functions
|
||||
# Functions
|
||||
|
||||
Every Rust program has at least one function, the `main` function:
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
% if
|
||||
# if
|
||||
|
||||
Rust’s take on `if` is not particularly complex, but it’s much more like the
|
||||
`if` you’ll find in a dynamically typed language than in a more traditional
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Iterators
|
||||
# Iterators
|
||||
|
||||
Let's talk about loops.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Lifetimes
|
||||
# Lifetimes
|
||||
|
||||
This guide is three of three presenting Rust’s ownership system. This is one of
|
||||
Rust’s most unique and compelling features, with which Rust developers should
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Loops
|
||||
# Loops
|
||||
|
||||
Rust currently provides three approaches to performing some kind of iterative activity. They are: `loop`, `while` and `for`. Each approach has its own set of uses.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Macros
|
||||
# Macros
|
||||
|
||||
By now you’ve learned about many of the tools Rust provides for abstracting and
|
||||
reusing code. These units of code reuse have a rich semantic structure. For
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Ownership
|
||||
# Ownership
|
||||
|
||||
This guide is one of three presenting Rust’s ownership system. This is one of
|
||||
Rust’s most unique and compelling features, with which Rust developers should
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Primitive Types
|
||||
# Primitive Types
|
||||
|
||||
The Rust language has a number of types that are considered ‘primitive’. This
|
||||
means that they’re built-in to the language. Rust is structured in such a way
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Raw Pointers
|
||||
# Raw Pointers
|
||||
|
||||
Rust has a number of different smart pointer types in its standard library, but
|
||||
there are two types that are extra-special. Much of Rust’s safety comes from
|
||||
|
@ -1,4 +1,4 @@
|
||||
% References and Borrowing
|
||||
# References and Borrowing
|
||||
|
||||
This guide is two of three presenting Rust’s ownership system. This is one of
|
||||
Rust’s most unique and compelling features, with which Rust developers should
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Structs
|
||||
# Structs
|
||||
|
||||
`struct`s are a way of creating more complex data types. For example, if we were
|
||||
doing calculations involving coordinates in 2D space, we would need both an `x`
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Testing
|
||||
# Testing
|
||||
|
||||
> Program testing can be a very effective way to show the presence of bugs, but
|
||||
> it is hopelessly inadequate for showing their absence.
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Trait Objects
|
||||
# Trait Objects
|
||||
|
||||
When code involves polymorphism, there needs to be a mechanism to determine
|
||||
which specific version is actually run. This is called ‘dispatch’. There are
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Traits
|
||||
# Traits
|
||||
|
||||
A trait is a language feature that tells the Rust compiler about
|
||||
functionality a type must provide.
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Universal Function Call Syntax
|
||||
# Universal Function Call Syntax
|
||||
|
||||
Sometimes, functions can have the same names. Consider this code:
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Unsafe
|
||||
# Unsafe
|
||||
|
||||
Rust’s main draw is its powerful static guarantees about behavior. But safety
|
||||
checks are conservative by nature: there are some programs that are actually
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Rust Inside Other Languages
|
||||
# Using Rust From Other Languages
|
||||
|
||||
For our third project, we’re going to choose something that shows off one of
|
||||
Rust’s greatest strengths: a lack of a substantial runtime.
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Variable Bindings
|
||||
# Variable Bindings
|
||||
|
||||
Virtually every non-'Hello World’ Rust program uses *variable bindings*. They
|
||||
bind some value to a name, so it can be used later. `let` is
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Vectors
|
||||
# Vectors
|
||||
|
||||
A ‘vector’ is a dynamic or ‘growable’ array, implemented as the standard
|
||||
library type [`Vec<T>`][vec]. The `T` means that we can have vectors
|
||||
|
Loading…
Reference in New Issue
Block a user