diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/doc/book/redirects | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/doc/book/redirects')
59 files changed, 1378 insertions, 0 deletions
diff --git a/src/doc/book/redirects/README.md b/src/doc/book/redirects/README.md new file mode 100644 index 000000000..6540e789f --- /dev/null +++ b/src/doc/book/redirects/README.md @@ -0,0 +1,11 @@ +% The Rust Programming Language + +There are two editions of "The Rust Programming Language": + +* [First edition](first-edition/index.html) +* [Second edition](second-edition/index.html) + +The second edition is a complete re-write. It is still under construction; +though it is far enough along to learn most of Rust; we suggest reading the +second edition and then checking out the first edition later to pick up some of +the more esoteric parts of the language. diff --git a/src/doc/book/redirects/SUMMARY.md b/src/doc/book/redirects/SUMMARY.md new file mode 100644 index 000000000..6540e789f --- /dev/null +++ b/src/doc/book/redirects/SUMMARY.md @@ -0,0 +1,11 @@ +% The Rust Programming Language + +There are two editions of "The Rust Programming Language": + +* [First edition](first-edition/index.html) +* [Second edition](second-edition/index.html) + +The second edition is a complete re-write. It is still under construction; +though it is far enough along to learn most of Rust; we suggest reading the +second edition and then checking out the first edition later to pick up some of +the more esoteric parts of the language. diff --git a/src/doc/book/redirects/associated-types.md b/src/doc/book/redirects/associated-types.md new file mode 100644 index 000000000..b222f3298 --- /dev/null +++ b/src/doc/book/redirects/associated-types.md @@ -0,0 +1,17 @@ +% Associated Types + +<small>There is a new edition of the book and this is an old link.</small> + +> Associated types are a way of associating a type placeholder with a trait such that the trait method definitions can use these placeholder types in their signatures. + +```rust +pub trait Iterator { + type Item; + fn next(&mut self) -> Option<Self::Item>; +} +``` + +--- + +You can find the latest version of this information +[here](ch19-03-advanced-traits.html#specifying-placeholder-types-in-trait-definitions-with-associated-types).
\ No newline at end of file diff --git a/src/doc/book/redirects/attributes.md b/src/doc/book/redirects/attributes.md new file mode 100644 index 000000000..812cbbcd3 --- /dev/null +++ b/src/doc/book/redirects/attributes.md @@ -0,0 +1,24 @@ +% Attributes + +<small>There is a new edition of the book and this is an old link.</small> + +> Any item declaration may have an attribute applied to it. + +```rust +// A function marked as a unit test +#[test] +fn test_foo() { + /* ... */ +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[In the Rust Reference: Ch 6.5 — Attributes][2]** +* <small>[In the first edition: Ch 3.27 — Attributes][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/attributes.html +[2]: ../reference/attributes.html diff --git a/src/doc/book/redirects/bibliography.md b/src/doc/book/redirects/bibliography.md new file mode 100644 index 000000000..aca777e39 --- /dev/null +++ b/src/doc/book/redirects/bibliography.md @@ -0,0 +1,14 @@ +% Bibliography + +<small>There is a new edition of the book and this is an old link.</small> + +This page does not exist in [the second edition][2]. +You might be interested in a similar page in [the Rust Reference][3]. + +* **[In the Rust Reference: Appendix — Influences][3]** +* <small>[In the first edition: Section 7 — Bibliography][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/bibliography.html +[2]: index.html +[3]: ../reference/influences.html diff --git a/src/doc/book/redirects/borrow-and-asref.md b/src/doc/book/redirects/borrow-and-asref.md new file mode 100644 index 000000000..6541e59ba --- /dev/null +++ b/src/doc/book/redirects/borrow-and-asref.md @@ -0,0 +1,25 @@ +% Borrow and AsRef + +<small>There is a new edition of the book and this is an old link.</small> + +> A cheap reference-to-reference conversion. +> Used to convert a value to a reference value within generic code. + +```rust +fn is_hello<T: AsRef<str>>(s: T) { + assert_eq!("hello", s.as_ref()); +} +``` + +--- + +This chapter does not exist in [the second edition][2]. +The best place to learn more about this is [the Rust documentation][3]. + +* **[In the Rust documentation: `convert::AsRef`][3]** +* <small>[In the first edition: Ch 4.10 — Borrow and AsRef][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/borrow-and-asref.html +[2]: index.html +[3]: ../std/convert/trait.AsRef.html diff --git a/src/doc/book/redirects/casting-between-types.md b/src/doc/book/redirects/casting-between-types.md new file mode 100644 index 000000000..7e1eb7744 --- /dev/null +++ b/src/doc/book/redirects/casting-between-types.md @@ -0,0 +1,32 @@ +% Casting between types + +<small>There is a new edition of the book and this is an old link.</small> + +> A type cast expression is denoted with the binary operator `as`. +> Executing an `as` expression casts the value on the left-hand side to the type on the right-hand side. + +```rust +# fn sum(values: &[f64]) -> f64 { 0.0 } +# fn len(values: &[f64]) -> i32 { 0 } + +fn average(values: &[f64]) -> f64 { + let sum: f64 = sum(values); + let size: f64 = len(values) as f64; + sum / size +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Appendix A — Keywords][2]** +* [In the Rust Reference: Type Cast Expressions][3] +* [In the Rust documentation: `mem::transmute`][4] +* <small>[In the first edition: Ch 3.29 — Casting between types][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/casting-between-types.html +[2]: appendix-01-keywords.html +[3]: ../reference/expressions/operator-expr.html#type-cast-expressions +[4]: ../std/mem/fn.transmute.html
\ No newline at end of file diff --git a/src/doc/book/redirects/choosing-your-guarantees.md b/src/doc/book/redirects/choosing-your-guarantees.md new file mode 100644 index 000000000..3667258c6 --- /dev/null +++ b/src/doc/book/redirects/choosing-your-guarantees.md @@ -0,0 +1,22 @@ +% Choosing your Guarantees + +<small>There is a new edition of the book and this is an old link.</small> + +> Smart pointers are data structures that act like a pointer, but they also have additional metadata and capabilities. +> The different smart pointers defined in Rust’s standard library provide extra functionality beyond what references provide. + +```rust +let b = Box::new(5); +println!("b = {}", b); +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[In the current edition: Ch 15.00 — Smart Pointers][2]** +* <small>[In the first edition: Ch 4.8 — Choosing your Guarantees][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/choosing-your-guarantees.html +[2]: ch15-00-smart-pointers.html diff --git a/src/doc/book/redirects/closures.md b/src/doc/book/redirects/closures.md new file mode 100644 index 000000000..55b88767f --- /dev/null +++ b/src/doc/book/redirects/closures.md @@ -0,0 +1,28 @@ +% Closures + +<small>There is a new edition of the book and this is an old link.</small> + +> Anonymous functions you can save in a variable or pass as arguments to other functions. + +```rust +# use std::thread; +# use std::time::Duration; + +let expensive_closure = |num| { + println!("calculating slowly..."); + thread::sleep(Duration::from_secs(2)); + num +}; +# expensive_closure(5); +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 13.01 — Closures][2]** +* <small>[In the first edition: Ch 3.23 — Closures][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/closures.html +[2]: ch13-01-closures.html diff --git a/src/doc/book/redirects/comments.md b/src/doc/book/redirects/comments.md new file mode 100644 index 000000000..d8e94f7e9 --- /dev/null +++ b/src/doc/book/redirects/comments.md @@ -0,0 +1,23 @@ +% Comments + +<small>There is a new edition of the book and this is an old link.</small> + +> Comments must start with two slashes and continue until the end of the line. +> For comments that extend beyond a single line, you’ll need to include // on each line. + +```rust +// So we’re doing something complicated here, long enough that we need +// multiple lines of comments to do it! Whew! Hopefully, this comment will +// explain what’s going on. +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 3.04 — Comments][2]** +* <small>[In the first edition: Ch 3.4 — Comments][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/comments.html +[2]: ch03-04-comments.html diff --git a/src/doc/book/redirects/compiler-plugins.md b/src/doc/book/redirects/compiler-plugins.md new file mode 100644 index 000000000..66061adf5 --- /dev/null +++ b/src/doc/book/redirects/compiler-plugins.md @@ -0,0 +1,13 @@ +% Compiler Plugins + +<small>There is a new edition of the book and this is an old link.</small> + +> Compiler plugins are user-provided libraries that extend the compiler's behavior with new syntax extensions, lint checks, etc. + +--- + +This particular chapter has moved to [the Unstable Book][2]. + +* **[In the Unstable Rust Book: `plugin`][2]** + +[2]: ../unstable-book/language-features/plugin.html diff --git a/src/doc/book/redirects/concurrency.md b/src/doc/book/redirects/concurrency.md new file mode 100644 index 000000000..da7fb2fb0 --- /dev/null +++ b/src/doc/book/redirects/concurrency.md @@ -0,0 +1,17 @@ +% Concurrency + +<small>There is a new edition of the book and this is an old link.</small> + +> Historically, programming [concurrency] has been difficult and error prone: Rust hopes to change that. +> Fearless concurrency allows you to write code that’s free of subtle bugs and is easy to refactor without introducing new bugs. + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 16.00 — Fearless Concurrency][2]** +* <small>[In the first edition: Ch 4.6 — Concurrency][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/concurrency.html +[2]: ch16-00-concurrency.html diff --git a/src/doc/book/redirects/conditional-compilation.md b/src/doc/book/redirects/conditional-compilation.md new file mode 100644 index 000000000..b25c02f74 --- /dev/null +++ b/src/doc/book/redirects/conditional-compilation.md @@ -0,0 +1,28 @@ +% Conditional Compilation + +<small>There is a new edition of the book and this is an old link.</small> + +> Sometimes one wants to have different compiler outputs from the same code, depending on build target, such as targeted operating system, or to enable release builds. +> Configuration options are either provided by the compiler or passed in on the command line using. +> Rust code then checks for their presence using the `#[cfg(...)]` attribute + +```rust +// The function is only included in the build when compiling for macOS +#[cfg(target_os = "macos")] +fn macos_only() { + // ... +} +``` + +--- + +This particular chapter does not exist in [the second edition][2]. +The best place to learn about it is [the Rust Reference][3]. + +* **[In the Rust Reference: Ch 5 — Conditional Compilation][3]** +* <small>[In the first edition: Ch 4.3 — Conditional Compilation][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/conditional-compilation.html +[2]: index.html +[3]: ../reference/conditional-compilation.html diff --git a/src/doc/book/redirects/const-and-static.md b/src/doc/book/redirects/const-and-static.md new file mode 100644 index 000000000..b87bdd383 --- /dev/null +++ b/src/doc/book/redirects/const-and-static.md @@ -0,0 +1,21 @@ +% `const` and `static` + +<small>There is a new edition of the book and this is an old link.</small> + +> Constants are _always_ immutable, and may only be set to a constant expression, not the result of a function call or any other value that could only be computed at runtime. +> +> Global variables are called `static` in Rust. + +```rust +const MAX_POINTS: u32 = 100_000; +static HELLO_WORLD: &str = "Hello, world!"; +``` + +--- + +You can find the latest version about constants +[here](ch03-01-variables-and-mutability.html#constants), +and about statics +[here](ch19-01-unsafe-rust.html#accessing-or-modifying-a-mutable-static-variable). + + diff --git a/src/doc/book/redirects/crates-and-modules.md b/src/doc/book/redirects/crates-and-modules.md new file mode 100644 index 000000000..d526c9564 --- /dev/null +++ b/src/doc/book/redirects/crates-and-modules.md @@ -0,0 +1,28 @@ +% Crates and Modules + +<small>There is a new edition of the book and this is an old link.</small> + +> Rust has a module system that enables the reuse of code in an organized fashion. +> A module is a namespace that contains definitions of functions or types, and you can choose whether those definitions are visible outside their module (public) or not (private). +> +> A crate is a project that other people can pull into their projects as a dependency. + +```rust +mod network { + fn connect() { + } +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 7.01 — `mod` and the Filesystem][2]** +* [in the current edition: Ch 14.02 — Publishing a Crate to Crates.io][3] +* <small>[In the first edition: Ch 3.25 — Crates and Modules][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/crates-and-modules.html +[2]: ch07-00-managing-growing-projects-with-packages-crates-and-modules.html +[3]: ch14-02-publishing-to-crates-io.html diff --git a/src/doc/book/redirects/deref-coercions.md b/src/doc/book/redirects/deref-coercions.md new file mode 100644 index 000000000..61d407e1d --- /dev/null +++ b/src/doc/book/redirects/deref-coercions.md @@ -0,0 +1,30 @@ +% Deref coercions + +<small>There is a new edition of the book and this is an old link.</small> + +> Implementing the `Deref` trait allows us to customize the behavior of the _dereference operator_ `*`. +> By implementing `Deref` in such a way that a smart pointer can be treated like a regular reference, we can write code that operates on references and use that code with smart pointers too. + +```rust +use std::ops::Deref; + +# struct MyBox<T>(T); +impl<T> Deref for MyBox<T> { + type Target = T; + + fn deref(&self) -> &T { + &self.0 + } +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 15.02 — Treating Smart Pointers like Regular References with the `Deref` Trait][2]** +* <small>[In the first edition: Ch 3.33 — Deref coercions][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/deref-coercions.html +[2]: ch15-02-deref.html diff --git a/src/doc/book/redirects/documentation.md b/src/doc/book/redirects/documentation.md new file mode 100644 index 000000000..ac7c881de --- /dev/null +++ b/src/doc/book/redirects/documentation.md @@ -0,0 +1,26 @@ +% Documentation + +<small>There is a new edition of the book and this is an old link.</small> + +> Documentation comments use `///` instead of `//` and support Markdown notation for formatting the text if you’d like. +> You place documentation comments just before the item they are documenting. + +```rust,no_run +/// Adds one to the number given. +/// +/// # Examples +/// +/// ``` +/// let five = 5; +/// +/// assert_eq!(6, my_crate::add_one(5)); +/// ``` +pub fn add_one(x: i32) -> i32 { + x + 1 +} +``` + +--- + +You can find the latest version of this information +[here](ch14-02-publishing-to-crates-io.html#making-useful-documentation-comments).
\ No newline at end of file diff --git a/src/doc/book/redirects/drop.md b/src/doc/book/redirects/drop.md new file mode 100644 index 000000000..164f1d745 --- /dev/null +++ b/src/doc/book/redirects/drop.md @@ -0,0 +1,34 @@ +% Drop + +<small>There is a new edition of the book and this is an old link.</small> + +> `Drop` lets us customize what happens when a value is about to go out of scope. + +```rust +struct CustomSmartPointer { + data: String, +} + +impl Drop for CustomSmartPointer { + fn drop(&mut self) { + println!("Dropping CustomSmartPointer with data `{}`!", self.data); + } +} + +fn main() { + let c = CustomSmartPointer { data: String::from("my stuff") }; + let d = CustomSmartPointer { data: String::from("other stuff") }; + println!("CustomSmartPointers created."); +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 15.03 — The `Drop` Trait Runs Code on Cleanup][2]** +* <small>[In the first edition: Ch 3.20 — Drop][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/drop.html +[2]: ch15-03-drop.html diff --git a/src/doc/book/redirects/effective-rust.md b/src/doc/book/redirects/effective-rust.md new file mode 100644 index 000000000..30312a3dd --- /dev/null +++ b/src/doc/book/redirects/effective-rust.md @@ -0,0 +1,14 @@ +% Effective Rust + +<small>There is a new edition of the book and this is an old link.</small> + +This section does not exist in [the second edition][2]. +However, the second edition encourages writing effective Rust from the start. +It is recommended to start there. + +* **[The second edition of The Rust Programming Language][2]** +* <small>[In the first edition: Ch 4 — Effective Rust][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/effective-rust.html +[2]: index.html diff --git a/src/doc/book/redirects/enums.md b/src/doc/book/redirects/enums.md new file mode 100644 index 000000000..c770d6b00 --- /dev/null +++ b/src/doc/book/redirects/enums.md @@ -0,0 +1,23 @@ +% Enums + +<small>There is a new edition of the book and this is an old link.</small> + +> Enums allow you to define a type by enumerating its possible values. + +```rust +enum IpAddrKind { + V4, + V6, +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 6.01 — Defining an Enum][2]** +* <small>[In the first edition: Ch 3.13 — Enums][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/enums.html +[2]: ch06-01-defining-an-enum.html diff --git a/src/doc/book/redirects/error-handling.md b/src/doc/book/redirects/error-handling.md new file mode 100644 index 000000000..7abc9642b --- /dev/null +++ b/src/doc/book/redirects/error-handling.md @@ -0,0 +1,16 @@ +% Error Handling + +<small>There is a new edition of the book and this is an old link.</small> + +> Rust groups errors into two major categories: _recoverable_ errors with `Result<T, E>` and _unrecoverable_ errors with `panic!`. + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 9.00 — Error Handling][2]** +* <small>[In the first edition: Ch 4.7 — Error Handling][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/error-handling.html +[2]: ch09-00-error-handling.html diff --git a/src/doc/book/redirects/ffi.md b/src/doc/book/redirects/ffi.md new file mode 100644 index 000000000..20ed3963e --- /dev/null +++ b/src/doc/book/redirects/ffi.md @@ -0,0 +1,23 @@ +% FFI + +<small>There is a new edition of the book and this is an old link.</small> + +> Sometimes, your Rust code may need to interact with code written in another language. +> To do this, Rust has a keyword, `extern`, that facilitates creating and using a _Foreign Function Interface_ (FFI). + +```rust +extern "C" { + fn abs(input: i32) -> i32; +} + +fn main() { + unsafe { + println!("Absolute value of -3 according to C: {}", abs(-3)); + } +} +``` + +--- + +You can find the latest version of this information +[here](ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code)
\ No newline at end of file diff --git a/src/doc/book/redirects/functions.md b/src/doc/book/redirects/functions.md new file mode 100644 index 000000000..eecbfd49c --- /dev/null +++ b/src/doc/book/redirects/functions.md @@ -0,0 +1,30 @@ +% Functions + +<small>There is a new edition of the book and this is an old link.</small> + +> Function definitions in Rust start with `fn` and have a set of parentheses after the function name. +> The curly brackets tell the compiler where the function body begins and ends. +> We can call any function we’ve defined by entering its name followed by a set of parentheses. + +```rust +fn main() { + println!("Hello, world!"); + + another_function(); +} + +fn another_function() { + println!("Another function."); +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[In the first edition: Ch 3.2 — Functions][1]** +* <small>[in the current edition: Ch 3.03 — Functions][2]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/functions.html +[2]: ch03-03-how-functions-work.html diff --git a/src/doc/book/redirects/generics.md b/src/doc/book/redirects/generics.md new file mode 100644 index 000000000..80700973f --- /dev/null +++ b/src/doc/book/redirects/generics.md @@ -0,0 +1,30 @@ +% Generics + +<small>There is a new edition of the book and this is an old link.</small> + +> Generics are abstract stand-ins for concrete types or other properties. + +```rust +struct Point<T, U> { + x: T, + y: U, +} + +fn main() { + let both_integer = Point { x: 5, y: 10 }; + let both_float = Point { x: 1.0, y: 4.0 }; + let integer_and_float = Point { x: 5, y: 4.0 }; +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 10.00 — Generic Types, Traits, and Lifetimes][2]** +* <small>[In the first edition: Ch 3.18 — Generics][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/generics.html +[2]: ch10-00-generics.html + diff --git a/src/doc/book/redirects/getting-started.md b/src/doc/book/redirects/getting-started.md new file mode 100644 index 000000000..1c84cbbaf --- /dev/null +++ b/src/doc/book/redirects/getting-started.md @@ -0,0 +1,13 @@ +% Getting Started + +<small>There is a new edition of the book and this is an old link.</small> + +You can [continue to the exact older page][1]. +If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. + +* **[in the current edition: Getting Started][2]** +* <small>[In the first edition: Getting Started][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/getting-started.html +[2]: ch01-00-getting-started.html diff --git a/src/doc/book/redirects/glossary.md b/src/doc/book/redirects/glossary.md new file mode 100644 index 000000000..c0f9f8e72 --- /dev/null +++ b/src/doc/book/redirects/glossary.md @@ -0,0 +1,14 @@ +% Glossary + +<small>There is a new edition of the book and this is an old link.</small> + +This section does not exist in [the second edition][2]. +However, the second edition defines the terms it uses inline, rather than using a glossary. +It is recommended to start there. + +* **[The second edition of The Rust Programming Language][2]** +* <small>[In the first edition: Glossary][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/glossary.html +[2]: index.html diff --git a/src/doc/book/redirects/guessing-game.md b/src/doc/book/redirects/guessing-game.md new file mode 100644 index 000000000..6abf4023b --- /dev/null +++ b/src/doc/book/redirects/guessing-game.md @@ -0,0 +1,12 @@ +% Tutorial: Guessing Game + +<small>There is a new edition of the book and this is an old link.</small> + +If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. + +* **[In the first edition: Tutorial — Guessing Game][1]** +* <small>[in the current edition: Ch 2.00 — Guessing Game tutorial][2]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/guessing-game.html +[2]: ch02-00-guessing-game-tutorial.html diff --git a/src/doc/book/redirects/if-let.md b/src/doc/book/redirects/if-let.md new file mode 100644 index 000000000..edbe5d88b --- /dev/null +++ b/src/doc/book/redirects/if-let.md @@ -0,0 +1,22 @@ +% if let + +<small>There is a new edition of the book and this is an old link.</small> + +> The `if let` syntax lets you combine `if` and `let` into a less verbose way to handle values that match one pattern and ignore the rest. + +```rust +let some_u8_value = Some(3u8); +if let Some(3) = some_u8_value { + println!("three"); +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* [In the current edition: Ch 6.03 — Concise Control Flow with `if let`][2] +* <small>[In the first edition: Ch 3.21 — if let][1]</small> + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/if-let.html +[2]: ch06-03-if-let.html diff --git a/src/doc/book/redirects/if.md b/src/doc/book/redirects/if.md new file mode 100644 index 000000000..ff97e94f1 --- /dev/null +++ b/src/doc/book/redirects/if.md @@ -0,0 +1,22 @@ +% if + +<small>There is a new edition of the book and this is an old link.</small> + +> An `if` expression allows us to branch our code depending on conditions. + +```rust +fn main() { + let number = 3; + + if number < 5 { + println!("condition was true"); + } else { + println!("condition was false"); + } +} +``` + +--- + +You can find the latest version of this information +[here](ch03-05-control-flow.html#if-expressions).
\ No newline at end of file diff --git a/src/doc/book/redirects/iterators.md b/src/doc/book/redirects/iterators.md new file mode 100644 index 000000000..26cb04766 --- /dev/null +++ b/src/doc/book/redirects/iterators.md @@ -0,0 +1,27 @@ +% Iterators + +<small>There is a new edition of the book and this is an old link.</small> + +> The iterator pattern allows you to perform some task on a sequence of items in turn. +> An iterator is responsible for the logic of iterating over each item and determining when the sequence has finished. + +```rust +let v1 = vec![1, 2, 3]; + +let v1_iter = v1.iter(); + +for val in v1_iter { + println!("Got: {}", val); +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 13.02 — Iterators][2]** +* <small>[In the first edition: Ch 4.5 — Iterators][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/iterators.html +[2]: ch13-02-iterators.html diff --git a/src/doc/book/redirects/lifetimes.md b/src/doc/book/redirects/lifetimes.md new file mode 100644 index 000000000..21ddb38ce --- /dev/null +++ b/src/doc/book/redirects/lifetimes.md @@ -0,0 +1,28 @@ +% Lifetimes + +<small>There is a new edition of the book and this is an old link.</small> + +> Every reference in Rust has a lifetime, which is the scope for which that reference is valid. +> Most of the time lifetimes are implicit and inferred. + +```rust +{ + let x = 5; // -----+-- 'b + // | + let r = &x; // --+--+-- 'a + // | | + println!("r: {}", r); // | | + // --+ | +} // -----+ +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 10.03 — Lifetimes][2]** +* <small>[In the first edition: Ch 3.10 — Lifetimes][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/lifetimes.html +[2]: ch10-03-lifetime-syntax.html diff --git a/src/doc/book/redirects/loops.md b/src/doc/book/redirects/loops.md new file mode 100644 index 000000000..1686c115e --- /dev/null +++ b/src/doc/book/redirects/loops.md @@ -0,0 +1,30 @@ +% Loops + +<small>There is a new edition of the book and this is an old link.</small> + +> Rust has three kinds of loops: `loop`, `while`, and `for`. +> The `loop` keyword tells Rust to execute a block of code over and over again forever or until you explicitly tell it to stop. +> `while` loops evaluate a block of code until a condition ceases to be true. +> A `for` loop executes some code for each item in a collection. + +```rust,no_run +loop { + println!("again!"); +} + +let mut number = 3; +while number != 0 { + println!("{}!", number); + number = number - 1; +} + +let a = [10, 20, 30, 40, 50]; +for element in a.iter() { + println!("the value is: {}", element); +} +``` + +--- + +You can find the latest version of this information +[here](ch03-05-control-flow.html#repetition-with-loops).
\ No newline at end of file diff --git a/src/doc/book/redirects/macros.md b/src/doc/book/redirects/macros.md new file mode 100644 index 000000000..08217d115 --- /dev/null +++ b/src/doc/book/redirects/macros.md @@ -0,0 +1,30 @@ +% Macros + +<small>There is a new edition of the book and this is an old link.</small> + +> While functions and types abstract over code, macros abstract at a syntactic level. + +```rust +macro_rules! five_times { + ($x:expr) => (5 * $x); +} + +fn main() { + assert_eq!(25, five_times!(2 + 3)); +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[In the current edition: Ch 19.06 Macros][2]** +* [Rust By Example: Macros][3] +* [In the Rust Reference: Ch 3.1 — Macros by Example][4] +* <small>[In the first edition: Ch 3.34 — Macros][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/macros.html +[2]: ch19-06-macros.html +[3]: https://rustbyexample.com/macros.html +[4]: ../reference/macros-by-example.html diff --git a/src/doc/book/redirects/match.md b/src/doc/book/redirects/match.md new file mode 100644 index 000000000..fd28ba8de --- /dev/null +++ b/src/doc/book/redirects/match.md @@ -0,0 +1,38 @@ +% Match + +<small>There is a new edition of the book and this is an old link.</small> + +> `match` allows us to compare a value against a series of patterns and then execute code based on which pattern matches. +> Patterns can be made up of literal values, variable names, wildcards, and many other things. + +```rust +enum Coin { + Penny, + Nickel, + Dime, + Quarter, +} + +fn value_in_cents(coin: Coin) -> u32 { + match coin { + Coin::Penny => 1, + Coin::Nickel => 5, + Coin::Dime => 10, + Coin::Quarter => 25, + } +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 6.02 — The `match` Control Flow Operator][2]** +* [in the current edition: Ch 18.00 — Patterns][3] +* <small>[In the first edition: Ch 3.14 — Match][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/match.html +[2]: ch06-02-match.html +[3]: ch18-00-patterns.html + diff --git a/src/doc/book/redirects/method-syntax.md b/src/doc/book/redirects/method-syntax.md new file mode 100644 index 000000000..29cd2cd7c --- /dev/null +++ b/src/doc/book/redirects/method-syntax.md @@ -0,0 +1,29 @@ +% Method Syntax + +<small>There is a new edition of the book and this is an old link.</small> + +> Methods are different from functions in that they’re defined within the context of a struct, and their first parameter is always `self`, which represents the instance of the struct the method is being called on. + +```rust +# struct Rectangle { +# width: u32, +# height: u32, +# } + +impl Rectangle { + fn area(&self) -> u32 { + self.width * self.height + } +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 5.03 — Method Syntax][2]** +* <small>[In the first edition: Ch 3.16 — Method Syntax][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/method-syntax.html +[2]: ch05-03-method-syntax.html diff --git a/src/doc/book/redirects/mutability.md b/src/doc/book/redirects/mutability.md new file mode 100644 index 000000000..89fc3b6f5 --- /dev/null +++ b/src/doc/book/redirects/mutability.md @@ -0,0 +1,23 @@ +% Mutability + +<small>There is a new edition of the book and this is an old link.</small> + +> Variables are immutable only by default; we can make them mutable by adding mut in front of the variable name. + +```rust +let mut x = 5; +println!("The value of x is: {}", x); +x = 6; +println!("The value of x is: {}", x); +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 3.01 — Variables and Mutability][2]** +* <small>[In the first edition: Ch 3.11 — Mutability][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/mutability.html +[2]: ch03-01-variables-and-mutability.html diff --git a/src/doc/book/redirects/operators-and-overloading.md b/src/doc/book/redirects/operators-and-overloading.md new file mode 100644 index 000000000..ff9a33048 --- /dev/null +++ b/src/doc/book/redirects/operators-and-overloading.md @@ -0,0 +1,36 @@ +% Operators and Overloading + +<small>There is a new edition of the book and this is an old link.</small> + +> Rust does not allow you to create your own operators or overload arbitrary operators, but the operations and corresponding traits listed in `std::ops` can be overloaded by implementing the traits associated with the operator. + +```rust +use std::ops::Add; + +#[derive(Debug,PartialEq)] +struct Point { + x: i32, + y: i32, +} + +impl Add for Point { + type Output = Point; + + fn add(self, other: Point) -> Point { + Point { + x: self.x + other.x, + y: self.y + other.y, + } + } +} + +fn main() { + assert_eq!(Point { x: 1, y: 0 } + Point { x: 2, y: 3 }, + Point { x: 3, y: 3 }); +} +``` + +--- + +You can find the latest version of this information +[here](ch19-03-advanced-traits.html). diff --git a/src/doc/book/redirects/ownership.md b/src/doc/book/redirects/ownership.md new file mode 100644 index 000000000..3e7ece3b4 --- /dev/null +++ b/src/doc/book/redirects/ownership.md @@ -0,0 +1,20 @@ +% Ownership + +<small>There is a new edition of the book and this is an old link.</small> + +> Ownership is Rust’s most unique feature, and it enables Rust to make memory safety guarantees without needing a garbage collector. +> +> 1. Each value in Rust has a variable that’s called its _owner_. +> 2. There can only be one owner at a time. +> 3. When the owner goes out of scope, the value will be dropped. + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 4.00 — Understanding Ownership][2]** +* <small>[In the first edition: Ch 3.8 — Ownership][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/ownership.html +[2]: ch04-00-understanding-ownership.html diff --git a/src/doc/book/redirects/patterns.md b/src/doc/book/redirects/patterns.md new file mode 100644 index 000000000..1936368b2 --- /dev/null +++ b/src/doc/book/redirects/patterns.md @@ -0,0 +1,23 @@ +% Patterns + +<small>There is a new edition of the book and this is an old link.</small> + +> Patterns are a special syntax within Rust for matching against the structure of our types, complex or simple. +> A pattern is made up of some combination of literals; destructured arrays, enums, structs, or tuples; variables, wildcards, and placeholders. +> These pieces describe the “shape” of the data we’re working with. + +```rust +let x = Some(5); +let y = 10; + +match x { + Some(50) => println!("Got 50"), + Some(y) => println!("Matched, y = {:?}", y), + _ => println!("Default case, x = {:?}", x), +} +``` + +--- + +You can find the latest version of this information +[here](ch06-02-match.html).
\ No newline at end of file diff --git a/src/doc/book/redirects/primitive-types.md b/src/doc/book/redirects/primitive-types.md new file mode 100644 index 000000000..aff51f782 --- /dev/null +++ b/src/doc/book/redirects/primitive-types.md @@ -0,0 +1,24 @@ +% Primitive Types + +<small>There is a new edition of the book and this is an old link.</small> + +> Rust is a _statically typed_ language, which means that it must know the types of all variables at compile time. +> The compiler can usually infer what type we want to use based on the value and how we use it. +> In cases when many types are possible, a _type annotation_ must be added. + +```rust +let x = 2.0; // f64 + +let y: f32 = 3.0; // f32 +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 3.02 — Data Types][2]** +* <small>[In the first edition: Ch 3.3 — Primitive Types][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/primitive-types.html +[2]: ch03-02-data-types.html diff --git a/src/doc/book/redirects/procedural-macros.md b/src/doc/book/redirects/procedural-macros.md new file mode 100644 index 000000000..bf6665f1a --- /dev/null +++ b/src/doc/book/redirects/procedural-macros.md @@ -0,0 +1,21 @@ +% Procedural Macros (and custom Derive) + +<small>There is a new edition of the book and this is an old link.</small> + +> Procedural macros allow for all sorts of advanced metaprogramming in Rust. + +--- + +This chapter does not exist yet in [the second edition][2]. +You can check out other resources that describe macros. + +* **[In the current edition: Ch 19.06 Macros][2]** +* [In the Rust Reference: Ch 3.2 — Procedural Macros][4] +* [The `proc_macro` crate documentation][3] +* <small>[In the first edition: Ch 4.13 — Procedural Macros (and custom Derive)][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/procedural-macros.html +[2]: ch19-06-macros.html +[3]: ../proc_macro/index.html +[4]: ../reference/procedural-macros.html diff --git a/src/doc/book/redirects/raw-pointers.md b/src/doc/book/redirects/raw-pointers.md new file mode 100644 index 000000000..773f3abc4 --- /dev/null +++ b/src/doc/book/redirects/raw-pointers.md @@ -0,0 +1,17 @@ +% Raw Pointers + +<small>There is a new edition of the book and this is an old link.</small> + +> Raw pointers are allowed to ignore many of the rules that references have to follow. + +```rust +let mut num = 5; + +let r1 = &num as *const i32; +let r2 = &mut num as *mut i32; +``` + +--- + +You can find the latest version of this information +[here](ch19-01-unsafe-rust.html#dereferencing-a-raw-pointer)
\ No newline at end of file diff --git a/src/doc/book/redirects/references-and-borrowing.md b/src/doc/book/redirects/references-and-borrowing.md new file mode 100644 index 000000000..7eb8da2bd --- /dev/null +++ b/src/doc/book/redirects/references-and-borrowing.md @@ -0,0 +1,24 @@ +% References and Borrowing + +<small>There is a new edition of the book and this is an old link.</small> + +> A reference _refers_ to a value but does not own it. +> Because it does not own it, the value it points to will not be dropped when the reference goes out of scope. + +```rust +fn calculate_length(s: &String) -> usize { // s is a reference to a String + s.len() +} // Here, s goes out of scope. But because it does not have ownership of what + // it refers to, nothing happens. +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 4.02 — References and Borrowing][2]** +* <small>[In the first edition: Ch 3.9 — References and Borrowing][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/references-and-borrowing.html +[2]: ch04-02-references-and-borrowing.html diff --git a/src/doc/book/redirects/release-channels.md b/src/doc/book/redirects/release-channels.md new file mode 100644 index 000000000..6e01e227f --- /dev/null +++ b/src/doc/book/redirects/release-channels.md @@ -0,0 +1,28 @@ +% Release Channels + +<small>There is a new edition of the book and this is an old link.</small> + +> The Rust project uses a concept called ‘release channels’ to manage releases. +> New nightly releases are created once a day. +> Every six weeks, the latest nightly release is promoted to ‘Beta’. +> At that point, it will only receive patches to fix serious errors. +> Six weeks later, the beta is promoted to ‘Stable’. + +--- + +This chapter does not exist yet in [the second edition][2]. +You can check out other resources that describe release channels. + +* **[In the Rustup documentation: Keeping Rust Up-to-date][4]** +* [On the website: Install Rust][5] +* [In the Rust RFCs: RFC 507 — Release Channels][3] +* [in the current edition: How Rust is Made and “Nightly Rust”][2] +* <small>[In the first edition: Ch 4.11 — Release Channels][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/release-channels.html +[2]: appendix-07-nightly-rust.html +[3]: https://github.com/rust-lang/rfcs/blob/master/text/0507-release-channels.md +[4]: https://github.com/rust-lang-nursery/rustup.rs/blob/master/README.md#keeping-rust-up-to-date +[5]: https://www.rust-lang.org/en-US/tools/install + diff --git a/src/doc/book/redirects/strings.md b/src/doc/book/redirects/strings.md new file mode 100644 index 000000000..3084e8d45 --- /dev/null +++ b/src/doc/book/redirects/strings.md @@ -0,0 +1,19 @@ +% Strings + +<small>There is a new edition of the book and this is an old link.</small> + +> A `String` is allocated on the heap and as such is able to store an amount of text that is unknown to us at compile time. +> You can create a `String` from a string literal using the `from` function. +> A _string slice_ is a reference to part of a `String`. + +```rust +let s = String::from("hello world"); + +let hello = &s[0..5]; +let world = &s[6..11]; +``` + +--- + +You can find the latest version of this information +[here](ch08-02-strings.html).
\ No newline at end of file diff --git a/src/doc/book/redirects/structs.md b/src/doc/book/redirects/structs.md new file mode 100644 index 000000000..5c5427c55 --- /dev/null +++ b/src/doc/book/redirects/structs.md @@ -0,0 +1,25 @@ +% Structs + +<small>There is a new edition of the book and this is an old link.</small> + +> A _struct_ is a custom data type that lets us name and package together multiple related values that make up a meaningful group. + +```rust +struct User { + username: String, + email: String, + sign_in_count: u64, + active: bool, +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[In second edition: Ch 5.00 — Structs][2]** +* <small>[In the first edition: Ch 3.12 — Structs][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/structs.html +[2]: ch05-00-structs.html diff --git a/src/doc/book/redirects/syntax-and-semantics.md b/src/doc/book/redirects/syntax-and-semantics.md new file mode 100644 index 000000000..b1f4f8aca --- /dev/null +++ b/src/doc/book/redirects/syntax-and-semantics.md @@ -0,0 +1,18 @@ +% Syntax and Semantics + +<small>There is a new edition of the book and this is an old link.</small> + +Here are the relevant sections in the new and old books: + + +* **[in the current edition: Ch 3.00 — Common Programming Concepts][2]** +* [in the current edition: Appendix A — Keywords][3] +* [in the current edition: Appendix B — Operators][4] +* <small>[In the first edition: Ch 3 — Syntax and Semantics][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/syntax-and-semantics.html +[2]: ch03-00-common-programming-concepts.html +[3]: appendix-01-keywords.html +[4]: appendix-02-operators.html + diff --git a/src/doc/book/redirects/syntax-index.md b/src/doc/book/redirects/syntax-index.md new file mode 100644 index 000000000..c9513bf0e --- /dev/null +++ b/src/doc/book/redirects/syntax-index.md @@ -0,0 +1,13 @@ +% Syntax Index + +<small>There is a new edition of the book and this is an old link.</small> + +Here are the relevant sections in the new and old books: + +* **[In the current edition: Appendix A — Keywords][2]** +* **[In the current edition: Appendix B — Operators][3]** +* <small>[In the first edition: Ch 6 — Syntax Index][1]</small> + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/syntax-index.html +[2]: appendix-01-keywords.html +[3]: appendix-02-operators.html diff --git a/src/doc/book/redirects/testing.md b/src/doc/book/redirects/testing.md new file mode 100644 index 000000000..f2030654f --- /dev/null +++ b/src/doc/book/redirects/testing.md @@ -0,0 +1,25 @@ +% Testing + +<small>There is a new edition of the book and this is an old link.</small> + +> Rust includes support for writing software tests within the language itself. + +```rust +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + } +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 11.00 — Testing][2]** +* <small>[In the first edition: Ch 4.2 — Testing][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/testing.html +[2]: ch11-00-testing.html diff --git a/src/doc/book/redirects/the-stack-and-the-heap.md b/src/doc/book/redirects/the-stack-and-the-heap.md new file mode 100644 index 000000000..e2d4d3ac9 --- /dev/null +++ b/src/doc/book/redirects/the-stack-and-the-heap.md @@ -0,0 +1,13 @@ +% The Stack and the Heap + +<small>There is a new edition of the book and this is an old link.</small> + +> Both the stack and the heap are parts of memory that is available to your code to use at runtime, but they are structured in different ways. +> The stack stores values in the order it gets them and removes the values in the opposite order. +> All data on the stack must take up a known, fixed size. +> For data with a size unknown to us at compile time or a size that might change, we can store data on the heap instead. + +--- + +You can find the latest version of this information +[here](ch04-01-what-is-ownership.html#the-stack-and-the-heap).
\ No newline at end of file diff --git a/src/doc/book/redirects/trait-objects.md b/src/doc/book/redirects/trait-objects.md new file mode 100644 index 000000000..3200e26a1 --- /dev/null +++ b/src/doc/book/redirects/trait-objects.md @@ -0,0 +1,68 @@ +% Trait Objects + +<small>There is a new edition of the book and this is an old link.</small> + +> Trait objects combine the data made up of the pointer to a concrete object with the behavior of the methods defined in the trait. +> A trait defines behavior that we need in a given situation. +> We can then use a trait as a trait object in places where we would use a concrete type or a generic type. + +```rust,ignore +pub struct InputBox { + pub label: String, +} + +impl Draw for InputBox { + fn draw(&self) { + // Code to actually draw an input box + } +} + +pub struct Button { + pub label: String, +} + +impl Draw for Button { + fn draw(&self) { + // Code to actually draw a button + } +} + +pub struct Screen<T: Draw> { + pub components: Vec<T>, +} + +impl<T> Screen<T> + where T: Draw { + pub fn run(&self) { + for component in self.components.iter() { + component.draw(); + } + } +} + +fn main() { + let screen = Screen { + components: vec![ + Box::new(InputBox { + label: String::from("OK"), + }), + Box::new(Button { + label: String::from("OK"), + }), + ], + }; + + screen.run(); +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 17.02 — Trait Objects][2]** +* <small>[In the first edition: Ch 3.22 — Trait Objects][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/trait-objects.html +[2]: ch17-02-trait-objects.html diff --git a/src/doc/book/redirects/traits.md b/src/doc/book/redirects/traits.md new file mode 100644 index 000000000..dcb577e97 --- /dev/null +++ b/src/doc/book/redirects/traits.md @@ -0,0 +1,24 @@ +% Traits + +<small>There is a new edition of the book and this is an old link.</small> + +> Traits abstract over behavior that types can have in common. + +```rust +pub trait Summarizable { + fn summary(&self) -> String; +} +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 10.02 — Traits][2]** +* [in the current edition: Ch 19.03 — Advanced Traits][3] +* <small>[In the first edition: Ch 3.19 — Traits][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/traits.html +[2]: ch10-02-traits.html +[3]: ch19-03-advanced-traits.html diff --git a/src/doc/book/redirects/type-aliases.md b/src/doc/book/redirects/type-aliases.md new file mode 100644 index 000000000..85cd4c9ec --- /dev/null +++ b/src/doc/book/redirects/type-aliases.md @@ -0,0 +1,14 @@ +% `type` aliases + +<small>There is a new edition of the book and this is an old link.</small> + +> Rust provides the ability to declare a _type alias_ with the `type` keyword to give an existing type another name. + +```rust +type Kilometers = i32; +``` + +--- + +You can find the latest version of this information +[here](ch19-04-advanced-types.html#creating-type-synonyms-with-type-aliases).
\ No newline at end of file diff --git a/src/doc/book/redirects/ufcs.md b/src/doc/book/redirects/ufcs.md new file mode 100644 index 000000000..2959c06bd --- /dev/null +++ b/src/doc/book/redirects/ufcs.md @@ -0,0 +1,48 @@ +% Universal Function Call Syntax + +<small>There is a new edition of the book and this is an old link.</small> + +> Rust cannot prevent a trait from having a method with the same name as another trait’s method, nor can it prevent us from implementing both of these traits on one type. +> In order to be able to call each of the methods with the same name, then, we need to tell Rust which one we want to use. + +```rust +trait Pilot { + fn fly(&self); +} + +trait Wizard { + fn fly(&self); +} + +struct Human; + +impl Pilot for Human { +# fn fly(&self) { +# println!("This is your captain speaking."); +# } +} + +impl Wizard for Human { +# fn fly(&self) { +# println!("Up!"); +# } +} + +impl Human { +# fn fly(&self) { +# println!("*waving arms furiously*"); +# } +} + +fn main() { + let person = Human; + Pilot::fly(&person); + Wizard::fly(&person); + person.fly(); +} +``` + +--- + +You can find the latest version of this information +[here](ch19-03-advanced-traits.html#fully-qualified-syntax-for-disambiguation-calling-methods-with-the-same-name).
\ No newline at end of file diff --git a/src/doc/book/redirects/unsafe.md b/src/doc/book/redirects/unsafe.md new file mode 100644 index 000000000..8628c7aa9 --- /dev/null +++ b/src/doc/book/redirects/unsafe.md @@ -0,0 +1,18 @@ +% `unsafe` + +<small>There is a new edition of the book and this is an old link.</small> + +> Rust has a second language hiding out inside of it, unsafe Rust, which does not enforce memory safety guarantees. + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 19.01 — Unsafe Rust][2]** +* [The Rustonomicon, The Dark Arts of Advanced and Unsafe Rust Programming][3] +* <small>[In the first edition: Ch 3.36 — `unsafe`][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/unsafe.html +[2]: ch19-01-unsafe-rust.html +[3]: ../nomicon/index.html diff --git a/src/doc/book/redirects/unsized-types.md b/src/doc/book/redirects/unsized-types.md new file mode 100644 index 000000000..bd9582cba --- /dev/null +++ b/src/doc/book/redirects/unsized-types.md @@ -0,0 +1,18 @@ +% Unsized Types + +<small>There is a new edition of the book and this is an old link.</small> + +> Sometimes referred to as ‘DSTs’ or ‘unsized types’, these types let us talk about types whose size we can only know at runtime. +> The `Sized` trait is automatically implemented for everything the compiler knows the size of at compile time. +> A trait bound on `?Sized` is the opposite of a trait bound on `Sized`; that is, we would read this as “`T` may or may not be `Sized`”. + +```rust,ignore +fn generic<T: ?Sized>(t: &T) { + // ...snip... +} +``` + +--- + +You can find the latest version of this information +[here](ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait).
\ No newline at end of file diff --git a/src/doc/book/redirects/using-rust-without-the-standard-library.md b/src/doc/book/redirects/using-rust-without-the-standard-library.md new file mode 100644 index 000000000..75145429d --- /dev/null +++ b/src/doc/book/redirects/using-rust-without-the-standard-library.md @@ -0,0 +1,17 @@ +% Using Rust without the Standard Library + +<small>There is a new edition of the book and this is an old link.</small> + +> Rust’s standard library provides a lot of useful functionality, but assumes support for various features of its host system: threads, networking, heap allocation, and others. +> There are systems that do not have these features, however. + +--- + +This particular chapter has moved to [the Unstable Book][2]. + +* **[In the Unstable Rust Book: `lang_items` — Writing an executable without stdlib][2]** +* <small>[In the first edition: Ch 4.12 — Using Rust without the Standard Library][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/using-rust-without-the-standard-library.html +[2]: ../unstable-book/language-features/lang-items.html#writing-an-executable-without-stdlib diff --git a/src/doc/book/redirects/variable-bindings.md b/src/doc/book/redirects/variable-bindings.md new file mode 100644 index 000000000..0bd437ec3 --- /dev/null +++ b/src/doc/book/redirects/variable-bindings.md @@ -0,0 +1,14 @@ +% Variable Bindings + +<small>There is a new edition of the book and this is an old link.</small> + +> Variable bindings bind some value to a name, so it can be used later. + +```rust +let foo = 5; +``` + +--- + +You can find the latest version of this information +[here](ch02-00-guessing-game-tutorial.html#storing-values-with-variables).
\ No newline at end of file diff --git a/src/doc/book/redirects/vectors.md b/src/doc/book/redirects/vectors.md new file mode 100644 index 000000000..1359f9da8 --- /dev/null +++ b/src/doc/book/redirects/vectors.md @@ -0,0 +1,23 @@ +% Vectors + +<small>There is a new edition of the book and this is an old link.</small> + +> Vectors store more than one value in a single data structure that puts all the values next to each other in memory. +> Vectors can only store values of the same type. + +```rust +let v: Vec<i32> = Vec::new(); +let numbers = vec![1, 2, 3]; +``` + +--- + +Here are the relevant sections in the new and old books: + +* **[in the current edition: Ch 8.01 — Vectors][2]** +* <small>[In the first edition: Ch 3.7 — Vectors][1]</small> + + +[1]: https://doc.rust-lang.org/1.30.0/book/first-edition/vectors.html +[2]: ch08-01-vectors.html + |