Port TRPL to mdbook
1. move everything under a src directory 2. add README.md to the SUMMARY.md
This commit is contained in:
parent
a076961fd0
commit
e943e68a47
@ -1,70 +0,0 @@
|
||||
# Summary
|
||||
|
||||
* [Getting Started](getting-started.md)
|
||||
* [Tutorial: Guessing Game](guessing-game.md)
|
||||
* [Syntax and Semantics](syntax-and-semantics.md)
|
||||
* [Variable Bindings](variable-bindings.md)
|
||||
* [Functions](functions.md)
|
||||
* [Primitive Types](primitive-types.md)
|
||||
* [Comments](comments.md)
|
||||
* [if](if.md)
|
||||
* [Loops](loops.md)
|
||||
* [Vectors](vectors.md)
|
||||
* [Ownership](ownership.md)
|
||||
* [References and Borrowing](references-and-borrowing.md)
|
||||
* [Lifetimes](lifetimes.md)
|
||||
* [Mutability](mutability.md)
|
||||
* [Structs](structs.md)
|
||||
* [Enums](enums.md)
|
||||
* [Match](match.md)
|
||||
* [Patterns](patterns.md)
|
||||
* [Method Syntax](method-syntax.md)
|
||||
* [Strings](strings.md)
|
||||
* [Generics](generics.md)
|
||||
* [Traits](traits.md)
|
||||
* [Drop](drop.md)
|
||||
* [if let](if-let.md)
|
||||
* [Trait Objects](trait-objects.md)
|
||||
* [Closures](closures.md)
|
||||
* [Universal Function Call Syntax](ufcs.md)
|
||||
* [Crates and Modules](crates-and-modules.md)
|
||||
* [`const` and `static`](const-and-static.md)
|
||||
* [Attributes](attributes.md)
|
||||
* [`type` aliases](type-aliases.md)
|
||||
* [Casting between types](casting-between-types.md)
|
||||
* [Associated Types](associated-types.md)
|
||||
* [Unsized Types](unsized-types.md)
|
||||
* [Operators and Overloading](operators-and-overloading.md)
|
||||
* [Deref coercions](deref-coercions.md)
|
||||
* [Macros](macros.md)
|
||||
* [Raw Pointers](raw-pointers.md)
|
||||
* [`unsafe`](unsafe.md)
|
||||
* [Effective Rust](effective-rust.md)
|
||||
* [The Stack and the Heap](the-stack-and-the-heap.md)
|
||||
* [Testing](testing.md)
|
||||
* [Conditional Compilation](conditional-compilation.md)
|
||||
* [Documentation](documentation.md)
|
||||
* [Iterators](iterators.md)
|
||||
* [Concurrency](concurrency.md)
|
||||
* [Error Handling](error-handling.md)
|
||||
* [Choosing your Guarantees](choosing-your-guarantees.md)
|
||||
* [FFI](ffi.md)
|
||||
* [Borrow and AsRef](borrow-and-asref.md)
|
||||
* [Release Channels](release-channels.md)
|
||||
* [Using Rust without the standard library](using-rust-without-the-standard-library.md)
|
||||
* [Procedural Macros (and custom derive)](procedural-macros.md)
|
||||
* [Nightly Rust](nightly-rust.md)
|
||||
* [Compiler Plugins](compiler-plugins.md)
|
||||
* [Inline Assembly](inline-assembly.md)
|
||||
* [No stdlib](no-stdlib.md)
|
||||
* [Intrinsics](intrinsics.md)
|
||||
* [Lang items](lang-items.md)
|
||||
* [Advanced linking](advanced-linking.md)
|
||||
* [Benchmark Tests](benchmark-tests.md)
|
||||
* [Box Syntax and Patterns](box-syntax-and-patterns.md)
|
||||
* [Slice Patterns](slice-patterns.md)
|
||||
* [Associated Constants](associated-constants.md)
|
||||
* [Custom Allocators](custom-allocators.md)
|
||||
* [Glossary](glossary.md)
|
||||
* [Syntax Index](syntax-index.md)
|
||||
* [Bibliography](bibliography.md)
|
@ -1,4 +1,4 @@
|
||||
% The Rust Programming Language
|
||||
# The Rust Programming Language
|
||||
|
||||
Welcome! This book will teach you about the [Rust Programming Language][rust].
|
||||
Rust is a systems programming language focused on three goals: safety, speed,
|
@ -1,3 +1,72 @@
|
||||
# Summary
|
||||
|
||||
- [Chapter 1](./chapter_1.md)
|
||||
[Introduction](README.md)
|
||||
|
||||
* [Getting Started](getting-started.md)
|
||||
* [Tutorial: Guessing Game](guessing-game.md)
|
||||
* [Syntax and Semantics](syntax-and-semantics.md)
|
||||
* [Variable Bindings](variable-bindings.md)
|
||||
* [Functions](functions.md)
|
||||
* [Primitive Types](primitive-types.md)
|
||||
* [Comments](comments.md)
|
||||
* [if](if.md)
|
||||
* [Loops](loops.md)
|
||||
* [Vectors](vectors.md)
|
||||
* [Ownership](ownership.md)
|
||||
* [References and Borrowing](references-and-borrowing.md)
|
||||
* [Lifetimes](lifetimes.md)
|
||||
* [Mutability](mutability.md)
|
||||
* [Structs](structs.md)
|
||||
* [Enums](enums.md)
|
||||
* [Match](match.md)
|
||||
* [Patterns](patterns.md)
|
||||
* [Method Syntax](method-syntax.md)
|
||||
* [Strings](strings.md)
|
||||
* [Generics](generics.md)
|
||||
* [Traits](traits.md)
|
||||
* [Drop](drop.md)
|
||||
* [if let](if-let.md)
|
||||
* [Trait Objects](trait-objects.md)
|
||||
* [Closures](closures.md)
|
||||
* [Universal Function Call Syntax](ufcs.md)
|
||||
* [Crates and Modules](crates-and-modules.md)
|
||||
* [`const` and `static`](const-and-static.md)
|
||||
* [Attributes](attributes.md)
|
||||
* [`type` aliases](type-aliases.md)
|
||||
* [Casting between types](casting-between-types.md)
|
||||
* [Associated Types](associated-types.md)
|
||||
* [Unsized Types](unsized-types.md)
|
||||
* [Operators and Overloading](operators-and-overloading.md)
|
||||
* [Deref coercions](deref-coercions.md)
|
||||
* [Macros](macros.md)
|
||||
* [Raw Pointers](raw-pointers.md)
|
||||
* [`unsafe`](unsafe.md)
|
||||
* [Effective Rust](effective-rust.md)
|
||||
* [The Stack and the Heap](the-stack-and-the-heap.md)
|
||||
* [Testing](testing.md)
|
||||
* [Conditional Compilation](conditional-compilation.md)
|
||||
* [Documentation](documentation.md)
|
||||
* [Iterators](iterators.md)
|
||||
* [Concurrency](concurrency.md)
|
||||
* [Error Handling](error-handling.md)
|
||||
* [Choosing your Guarantees](choosing-your-guarantees.md)
|
||||
* [FFI](ffi.md)
|
||||
* [Borrow and AsRef](borrow-and-asref.md)
|
||||
* [Release Channels](release-channels.md)
|
||||
* [Using Rust without the standard library](using-rust-without-the-standard-library.md)
|
||||
* [Procedural Macros (and custom derive)](procedural-macros.md)
|
||||
* [Nightly Rust](nightly-rust.md)
|
||||
* [Compiler Plugins](compiler-plugins.md)
|
||||
* [Inline Assembly](inline-assembly.md)
|
||||
* [No stdlib](no-stdlib.md)
|
||||
* [Intrinsics](intrinsics.md)
|
||||
* [Lang items](lang-items.md)
|
||||
* [Advanced linking](advanced-linking.md)
|
||||
* [Benchmark Tests](benchmark-tests.md)
|
||||
* [Box Syntax and Patterns](box-syntax-and-patterns.md)
|
||||
* [Slice Patterns](slice-patterns.md)
|
||||
* [Associated Constants](associated-constants.md)
|
||||
* [Custom Allocators](custom-allocators.md)
|
||||
* [Glossary](glossary.md)
|
||||
* [Syntax Index](syntax-index.md)
|
||||
* [Bibliography](bibliography.md)
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Advanced Linking
|
||||
# Advanced Linking
|
||||
|
||||
The common cases of linking with Rust have been covered earlier in this book,
|
||||
but supporting the range of linking possibilities made available by other
|
@ -1,4 +1,4 @@
|
||||
% Associated Constants
|
||||
# Associated Constants
|
||||
|
||||
With the `associated_consts` feature, you can define constants like this:
|
||||
|
@ -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 @@
|
||||
% Attributes
|
||||
# Attributes
|
||||
|
||||
Declarations can be annotated with ‘attributes’ in Rust. They look like this:
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Benchmark tests
|
||||
# Benchmark tests
|
||||
|
||||
Rust supports benchmark tests, which can test the performance of your
|
||||
code. Let's make our `src/lib.rs` look like this (comments elided):
|
@ -1,4 +1,4 @@
|
||||
% Bibliography
|
||||
# Bibliography
|
||||
|
||||
This is a reading list of material relevant to Rust. It includes prior
|
||||
research that has - at one time or another - influenced the design of
|
@ -1,4 +1,4 @@
|
||||
% Borrow and AsRef
|
||||
# Borrow and AsRef
|
||||
|
||||
The [`Borrow`][borrow] and [`AsRef`][asref] traits are very similar, but
|
||||
different. Here’s a quick refresher on what these two traits mean.
|
@ -1,4 +1,4 @@
|
||||
% Box Syntax and Patterns
|
||||
# Box Syntax and Patterns
|
||||
|
||||
Currently the only stable way to create a `Box` is via the `Box::new` method.
|
||||
Also it is not possible in stable Rust to destructure a `Box` in a match
|
@ -1,4 +1,4 @@
|
||||
% Casting Between Types
|
||||
# Casting Between Types
|
||||
|
||||
Rust, with its focus on safety, provides two different ways of casting
|
||||
different types between each other. The first, `as`, is for safe casts.
|
||||
@ -19,7 +19,7 @@ The most common case of coercion is removing mutability from a reference:
|
||||
* `&mut T` to `&T`
|
||||
|
||||
An analogous conversion is to remove mutability from a
|
||||
[raw pointer](raw-pointers.md):
|
||||
[raw pointer](raw-pointers.html):
|
||||
|
||||
* `*mut T` to `*const T`
|
||||
|
||||
@ -29,7 +29,7 @@ References can also be coerced to raw pointers:
|
||||
|
||||
* `&mut T` to `*mut T`
|
||||
|
||||
Custom coercions may be defined using [`Deref`](deref-coercions.md).
|
||||
Custom coercions may be defined using [`Deref`](deref-coercions.html).
|
||||
|
||||
Coercion is transitive.
|
||||
|
||||
@ -101,7 +101,7 @@ The semantics of numeric casts are:
|
||||
|
||||
## Pointer casts
|
||||
|
||||
Perhaps surprisingly, it is safe to cast [raw pointers](raw-pointers.md) to and
|
||||
Perhaps surprisingly, it is safe to cast [raw pointers](raw-pointers.html) to and
|
||||
from integers, and to cast between pointers to different types subject to
|
||||
some constraints. It is only unsafe to dereference the pointer:
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Choosing your Guarantees
|
||||
# Choosing your Guarantees
|
||||
|
||||
One important feature of Rust is that it lets us control the costs and guarantees
|
||||
of a program.
|
@ -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 @@
|
||||
% Comments
|
||||
# Comments
|
||||
|
||||
Now that we have some functions, it’s a good idea to learn about comments.
|
||||
Comments are notes that you leave to other programmers to help explain things
|
@ -1,6 +1,6 @@
|
||||
% Compiler Plugins
|
||||
# Compiler Plugins
|
||||
|
||||
# Introduction
|
||||
## Introduction
|
||||
|
||||
`rustc` can load compiler plugins, which are user-provided libraries that
|
||||
extend the compiler's behavior with new syntax extensions, lint checks, etc.
|
@ -1,4 +1,4 @@
|
||||
% Concurrency
|
||||
# Concurrency
|
||||
|
||||
Concurrency and parallelism are incredibly important topics in computer
|
||||
science, and are also a hot topic in industry today. Computers are gaining more
|
@ -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 @@
|
||||
% const and static
|
||||
# const and static
|
||||
|
||||
Rust has a way of defining constants with the `const` keyword:
|
||||
|
@ -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 @@
|
||||
% Custom Allocators
|
||||
# Custom Allocators
|
||||
|
||||
Allocating memory isn't always the easiest thing to do, and while Rust generally
|
||||
takes care of this by default it often becomes necessary to customize how
|
@ -1,4 +1,4 @@
|
||||
% `Deref` coercions
|
||||
# `Deref` coercions
|
||||
|
||||
The standard library provides a special trait, [`Deref`][deref]. It’s normally
|
||||
used to overload `*`, the dereference operator:
|
@ -1,4 +1,4 @@
|
||||
% Documentation
|
||||
# Documentation
|
||||
|
||||
Documentation is an important part of any software project, and it's
|
||||
first-class in Rust. Let's talk about the tooling Rust gives you to
|
@ -1,4 +1,4 @@
|
||||
% Drop
|
||||
# Drop
|
||||
|
||||
Now that we’ve discussed traits, let’s talk about a particular trait provided
|
||||
by the Rust standard library, [`Drop`][drop]. The `Drop` trait provides a way
|
@ -1,4 +1,4 @@
|
||||
% Effective Rust
|
||||
# Effective Rust
|
||||
|
||||
So you’ve learned how to write some Rust code. But there’s a difference between
|
||||
writing *any* Rust code and writing *good* Rust code.
|
@ -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 @@
|
||||
% Error Handling
|
||||
# Error Handling
|
||||
|
||||
Like most programming languages, Rust encourages the programmer to handle
|
||||
errors in a particular way. Generally speaking, error handling is divided into
|
@ -1,4 +1,4 @@
|
||||
% Foreign Function Interface
|
||||
# Foreign Function Interface
|
||||
|
||||
# Introduction
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Functions
|
||||
# Functions
|
||||
|
||||
Every Rust program has at least one function, the `main` function:
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Generics
|
||||
# Generics
|
||||
|
||||
Sometimes, when writing a function or data type, we may want it to work for
|
||||
multiple types of arguments. In Rust, we can do this with generics.
|
@ -1,4 +1,4 @@
|
||||
% Getting Started
|
||||
# Getting Started
|
||||
|
||||
This first chapter of the book will get us going with Rust and its tooling.
|
||||
First, we’ll install Rust. Then, the classic ‘Hello World’ program. Finally,
|
@ -1,4 +1,4 @@
|
||||
% Glossary
|
||||
# Glossary
|
||||
|
||||
Not every Rustacean has a background in systems programming, nor in computer
|
||||
science, so we've added explanations of terms that might be unfamiliar.
|
@ -1,4 +1,4 @@
|
||||
% Guessing Game
|
||||
# Guessing Game
|
||||
|
||||
Let’s learn some Rust! For our first project, we’ll implement a classic
|
||||
beginner programming problem: the guessing game. Here’s how it works: Our
|
@ -1,4 +1,4 @@
|
||||
% if let
|
||||
# if let
|
||||
|
||||
`if let` permits [patterns][pattern] matching within the condition of an [if][if] statement.
|
||||
This allows us to reduce the overhead of certain kinds of [pattern][patterns] matches
|
@ -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 @@
|
||||
% Inline Assembly
|
||||
# Inline Assembly
|
||||
|
||||
For extremely low-level manipulations and performance reasons, one
|
||||
might wish to control the CPU directly. Rust supports using inline
|
@ -1,4 +1,4 @@
|
||||
% Intrinsics
|
||||
# Intrinsics
|
||||
|
||||
> **Note**: intrinsics will forever have an unstable interface, it is
|
||||
> recommended to use the stable interfaces of libcore rather than intrinsics
|
@ -1,4 +1,4 @@
|
||||
% Iterators
|
||||
# Iterators
|
||||
|
||||
Let's talk about loops.
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Lang items
|
||||
# Lang items
|
||||
|
||||
> **Note**: lang items are often provided by crates in the Rust distribution,
|
||||
> and lang items themselves have an unstable interface. It is recommended to use
|
@ -1,4 +1,4 @@
|
||||
% Lifetimes
|
||||
# Lifetimes
|
||||
|
||||
This is the last of three sections presenting Rust’s ownership system. This is one of
|
||||
Rust’s most distinct 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 @@
|
||||
% Match
|
||||
# Match
|
||||
|
||||
Often, a simple [`if`][if]/`else` isn’t enough, because you have more than two
|
||||
possible options. Also, conditions can get quite complex. Rust
|
@ -1,4 +1,4 @@
|
||||
% Method Syntax
|
||||
# Method Syntax
|
||||
|
||||
Functions are great, but if you want to call a bunch of them on some data, it
|
||||
can be awkward. Consider this code:
|
@ -1,4 +1,4 @@
|
||||
% Mutability
|
||||
# Mutability
|
||||
|
||||
Mutability, the ability to change something, works a bit differently in Rust
|
||||
than in other languages. The first aspect of mutability is its non-default
|
@ -1,8 +1,8 @@
|
||||
% Nightly Rust
|
||||
# Nightly Rust
|
||||
|
||||
Rust provides three distribution channels for Rust: nightly, beta, and stable.
|
||||
Unstable features are only available on nightly Rust. For more details on this
|
||||
process, see ‘[Stability as a deliverable][stability]’.
|
||||
process, see [Stability as a deliverable][stability].
|
||||
|
||||
[stability]: http://blog.rust-lang.org/2014/10/30/Stability.html
|
||||
|
||||
@ -91,9 +91,10 @@ If not, there are a number of places where you can get help. The easiest is
|
||||
[the #rust IRC channel on irc.mozilla.org][irc], which you can access through
|
||||
[Mibbit][mibbit]. Click that link, and you'll be chatting with other Rustaceans
|
||||
(a silly nickname we call ourselves), and we can help you out. Other great
|
||||
resources include [the user’s forum][users], and [Stack Overflow][stackoverflow].
|
||||
resources include [the users forum][users], and [Stack Overflow][stackoverflow].
|
||||
|
||||
[irc]: irc://irc.mozilla.org/#rust
|
||||
[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust
|
||||
[users]: https://users.rust-lang.org/
|
||||
[stackoverflow]: http://stackoverflow.com/questions/tagged/rust
|
||||
|
@ -1,4 +1,4 @@
|
||||
% No stdlib
|
||||
# No stdlib
|
||||
|
||||
Rust’s standard library provides a lot of useful functionality, but assumes
|
||||
support for various features of its host system: threads, networking, heap
|
@ -1,4 +1,4 @@
|
||||
% Operators and Overloading
|
||||
# Operators and Overloading
|
||||
|
||||
Rust allows for a limited form of operator overloading. There are certain
|
||||
operators that are able to be overloaded. To support a particular operator
|
@ -1,4 +1,4 @@
|
||||
% Ownership
|
||||
# Ownership
|
||||
|
||||
This is the first of three sections presenting Rust’s ownership system. This is one of
|
||||
Rust’s most distinct and compelling features, with which Rust developers should
|
@ -1,4 +1,4 @@
|
||||
% Patterns
|
||||
# Patterns
|
||||
|
||||
Patterns are quite common in Rust. We use them in [variable
|
||||
bindings][bindings], [match expressions][match], and other places, too. Let’s go
|
@ -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 @@
|
||||
% Procedural Macros (and custom Derive)
|
||||
# Procedural Macros (and custom Derive)
|
||||
|
||||
As you've seen throughout the rest of the book, Rust provides a mechanism
|
||||
called "derive" that lets you implement traits easily. For example,
|
@ -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 is the second of three sections presenting Rust’s ownership system. This is one of
|
||||
Rust’s most distinct and compelling features, with which Rust developers should
|
@ -1,4 +1,4 @@
|
||||
% Release Channels
|
||||
# Release Channels
|
||||
|
||||
The Rust project uses a concept called ‘release channels’ to manage releases.
|
||||
It’s important to understand this process to choose which version of Rust
|
@ -1,4 +1,4 @@
|
||||
% Slice patterns
|
||||
# Slice patterns
|
||||
|
||||
If you want to match against a slice or array, you can use `&` with the
|
||||
`slice_patterns` feature:
|
@ -1,4 +1,4 @@
|
||||
% Strings
|
||||
# Strings
|
||||
|
||||
Strings are an important concept for any programmer to master. Rust’s string
|
||||
handling system is a bit different from other languages, due to its systems
|
@ -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 @@
|
||||
% Syntax and Semantics
|
||||
# Syntax and Semantics
|
||||
|
||||
This chapter breaks Rust down into small chunks, one for each concept.
|
||||
|
@ -1,4 +1,4 @@
|
||||
% Syntax Index
|
||||
# Syntax Index
|
||||
|
||||
## Keywords
|
||||
|
@ -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 @@
|
||||
% The Stack and the Heap
|
||||
# The Stack and the Heap
|
||||
|
||||
As a systems language, Rust operates at a low level. If you’re coming from a
|
||||
high-level language, there are some aspects of systems programming that you may
|
@ -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 @@
|
||||
% Type Aliases
|
||||
# Type Aliases
|
||||
|
||||
The `type` keyword lets you declare an alias of another type:
|
||||
|
@ -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 @@
|
||||
% Unsized Types
|
||||
# Unsized Types
|
||||
|
||||
Most types have a particular size, in bytes, that is knowable at compile time.
|
||||
For example, an `i32` is thirty-two bits big, or four bytes. However, there are
|
@ -1,4 +1,4 @@
|
||||
% Using Rust Without the Standard Library
|
||||
# Using Rust Without the Standard Library
|
||||
|
||||
Rust’s standard library provides a lot of useful functionality, but assumes
|
||||
support for various features of its host system: threads, networking, heap
|
@ -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…
x
Reference in New Issue
Block a user