From 1d818fdb0201c5e7baaa1de6b05f38905c55008f Mon Sep 17 00:00:00 2001 From: Budo Zindovic Date: Tue, 25 Apr 2023 05:06:59 +0200 Subject: [PATCH 1/8] Fix the variable type Fix the type of variable type in the doc string. --- src/part04.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/part04.rs b/src/part04.rs index 21654cd..2381ff4 100644 --- a/src/part04.rs +++ b/src/part04.rs @@ -106,7 +106,7 @@ fn shared_ref_demo() { //@ their official name. //@ As an example, consider a function which increments every element of a vector by 1. -//@ The type `&mut Vec` is the type of mutable references to `vec`. Because the reference +//@ The type `&mut Vec` is the type of mutable references to `Vec`. Because the reference //@ is mutable, we can use a mutable iterator, providing mutable references to the elements. fn vec_inc(v: &mut Vec) { for e in v.iter_mut() { -- 2.39.5 From 04e6bfa1aab433e4cfb0058132f7b57258ddcd16 Mon Sep 17 00:00:00 2001 From: Budo Zindovic Date: Tue, 25 Apr 2023 09:48:59 +0200 Subject: [PATCH 2/8] Update part01.rs --- src/part01.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/part01.rs b/src/part01.rs index a4537ac..e00cf53 100644 --- a/src/part01.rs +++ b/src/part01.rs @@ -87,7 +87,7 @@ impl NumberOrNothing { //@ methods on an `enum` (and also on `struct`, which we will learn about later) //@ is independent of the definition of the type. `self` is like `this` in other //@ languages, and its type is always implicit. So `print` is now a method that -//@ takes as first argument a `NumberOrNothing`, just like `print_number_or_nothing`. +//@ takes `NumberOrNothing` as the first argument, just like `print_number_or_nothing`. //@ //@ Try making `number_or_default` from above an inherent method as well! -- 2.39.5 From 79b3d41f9ee58f167f757218da02f82cec8f811d Mon Sep 17 00:00:00 2001 From: Budo Zindovic Date: Tue, 25 Apr 2023 13:58:04 +0200 Subject: [PATCH 3/8] Fix a typo in part 6 Fix a typo in part 6 with character //@ appearing in rendered document. --- src/part06.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/part06.rs b/src/part06.rs index 939fe08..de90cb6 100644 --- a/src/part06.rs +++ b/src/part06.rs @@ -127,8 +127,8 @@ fn head(v: &Vec) -> Option<&T> { //@ have aliasing (of `first` and `v`) and mutation. But this time, the bug is hidden behind the //@ call to `head`. How does Rust solve this? If we translate the code above to Rust, it doesn't //@ compile, so clearly we are good - but how and why? -//@ (Notice that have to explicitly assert using //@ `unwrap` that `first` is not `None`, whereas -//@ the C++ code above would silently dereference a //@ `NULL`-pointer. But that's another point.) +//@ (Notice that have to explicitly assert using `unwrap` that `first` is not `None`, whereas +//@ the C++ code above would silently dereference a `NULL`-pointer. But that's another point.) fn rust_foo(mut v: Vec) -> i32 { let first: Option<&i32> = head(&v); /* v.push(42); */ -- 2.39.5 From a16f3d282a991ef1c28fded477f9a1d30c6f3b5c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 28 Apr 2023 15:34:47 +0200 Subject: [PATCH 4/8] more typos --- src/part06.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/part06.rs b/src/part06.rs index de90cb6..4c7ee24 100644 --- a/src/part06.rs +++ b/src/part06.rs @@ -127,7 +127,7 @@ fn head(v: &Vec) -> Option<&T> { //@ have aliasing (of `first` and `v`) and mutation. But this time, the bug is hidden behind the //@ call to `head`. How does Rust solve this? If we translate the code above to Rust, it doesn't //@ compile, so clearly we are good - but how and why? -//@ (Notice that have to explicitly assert using `unwrap` that `first` is not `None`, whereas +//@ (Notice that we use `unwrap` to explicitly assert that `first` is not `None`, whereas //@ the C++ code above would silently dereference a `NULL`-pointer. But that's another point.) fn rust_foo(mut v: Vec) -> i32 { let first: Option<&i32> = head(&v); -- 2.39.5 From fa343b9549ed103c387dc84fd581c4e69f418077 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 17 Aug 2023 13:39:57 +0200 Subject: [PATCH 5/8] use pipx instead of pip to install pycco --- Makefile | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c157dac..d8c0e44 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ docs: $(DOCFILES) @sed 's|^\(\s*//\)@|\1|;s|\s*/\*@\*/$$||;s|\(\s*\)\S.*/\*@@\*/|\1unimplemented!()|' $< | sed -f dup-unimpl.sed > $@ docs/%.html: .tmp/docs/%.rs - @./pycco-rs $< + ~/.local/pipx/venvs/pycco/bin/python pycco-rs $< ## Workspace # The generated files are shipped only for the benefit of Windows users, who diff --git a/README.md b/README.md index be0e4fb..494099f 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ The most accessible form of the tutorial is its ## Offline Usage You can either read through the sources in `src/`, or generate the -HTML in `docs/` using `make docs` (this step needs -[Pycco](https://pycco-docs.github.io/pycco/)). +HTML in `docs/` using `make docs`. This steps assumes `pipx install pycco` has +been run before; it will use the pipx-created venv to import pycco. The files `workspace/src/part*.rs` are generated by `make workspace`. -- 2.39.5 From bc8b6a556edacde1fcdb3bc9c1568373bc31d2d8 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 17 Aug 2023 13:40:24 +0200 Subject: [PATCH 6/8] update Cargo.lock formats --- Cargo.lock | 5 ++++- workspace/Cargo.lock | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3174aa5..c0bfd7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,4 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + [[package]] name = "rust-101" version = "0.1.0" - diff --git a/workspace/Cargo.lock b/workspace/Cargo.lock index 7111b99..3040431 100644 --- a/workspace/Cargo.lock +++ b/workspace/Cargo.lock @@ -1,4 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + [[package]] name = "rust-101-workspace" version = "0.0.0" - -- 2.39.5 From 0da6e9205576b3191f45190a18d1f7d1e33fb0ea Mon Sep 17 00:00:00 2001 From: Yiran Zhou Date: Wed, 27 Sep 2023 11:24:10 +0800 Subject: [PATCH 7/8] fix link to example --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 2a0aa76..66a0ed7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -119,7 +119,7 @@ fn main() { // // * [The Rust Book](https://doc.rust-lang.org/stable/book/) // * [The Rustonomicon](https://doc.rust-lang.org/nightly/nomicon/) -// * [Rust by Example](http://rustbyexample.com/) +// * [Rust by Example](https://doc.rust-lang.org/rust-by-example/) // * The [Rust Subreddit](https://www.reddit.com/r/rust/) // * A [collection of links](https://github.com/ctjhoa/rust-learning) to blog posts, articles, // videos, etc. for learning Rust. -- 2.39.5 From dbe5e64bd7e47fd8ab3f7e8b1dc22c55b1fb39f3 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 18 Jul 2024 12:14:31 +0200 Subject: [PATCH 8/8] add a note to the README about this being a tutorial for an ancient version of Rust --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 494099f..c163e7f 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ This documents Rust-101, a tutorial for the [Rust language](http://www.rust-lang.org/). +**Note that this tutorial was written for Rust 1.3 in 2015, and the language evolved a lot since then. +Some of the idioms presented here may no longer reflect current practice.** + ## Online tutorial The most accessible form of the tutorial is its -- 2.39.5