]> git.ralfj.de Git - rust-101.git/commitdiff
add a note to the README about this being a tutorial for an ancient version of Rust master
authorRalf Jung <post@ralfj.de>
Thu, 18 Jul 2024 10:14:31 +0000 (12:14 +0200)
committerRalf Jung <post@ralfj.de>
Thu, 18 Jul 2024 10:14:31 +0000 (12:14 +0200)
Cargo.lock
Makefile
README.md
src/main.rs
src/part01.rs
src/part04.rs
src/part06.rs
workspace/Cargo.lock

index 3174aa537aa1c97db9e698e255a82e088e34b76a..c0bfd7bf679df9d05934300c6e812b1e52481708 100644 (file)
@@ -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"
-
index c157dacd438510f9ca826f9cf0815e93f1b4b584..d8c0e443d6c5101db95df06a6d49046864d8daf0 100644 (file)
--- 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
index be0e4fb9d79875e94954084d6fef2916830b6f42..c163e7f6c1b67d57c529e5800e7a844e84c6bfd2 100644 (file)
--- 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
@@ -11,8 +14,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`.
 
index 2a0aa76d30fd3b2524b1a10a3630db83f92f4302..66a0ed746a4c183eccc249a9596d02ed42ee0a19 100644 (file)
@@ -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.
index a4537acbc18f05e621fc0b5d05cbbffd3bb7bfcd..e00cf536b397ae9eb73d5ca45758016c3fcae347 100644 (file)
@@ -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!
 
index 21654cd3cd46b827c71993408c989bc7a8301de5..2381ff4ed00a631618e342ee9abdd47d65253939 100644 (file)
@@ -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<i32>` is the type of mutable references to `vec<i32>`. Because the reference
+//@ The type `&mut Vec<i32>` is the type of mutable references to `Vec<i32>`. Because the reference
 //@ is mutable, we can use a mutable iterator, providing mutable references to the elements.
 fn vec_inc(v: &mut Vec<i32>) {
     for e in v.iter_mut() {
index 939fe081f8d601ad09b216bcb0f4990943159b36..4c7ee24fdeedfab73af6b88b05df989b37623297 100644 (file)
@@ -127,8 +127,8 @@ fn head<T>(v: &Vec<T>) -> 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 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>) -> i32 {
     let first: Option<&i32> = head(&v);
     /* v.push(42); */
index 7111b99a0319c6f7ad882c3dd87287c5fef37509..3040431a5aed05c90d237767ce4f652ba174f357 100644 (file)
@@ -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"
-