From 36e2990305bcc3eef04bd888bfafe9c9d3fe04d9 Mon Sep 17 00:00:00 2001 From: Luke Tidd Date: Tue, 2 May 2023 09:25:21 -0400 Subject: [PATCH] started book again --- .gitignore | 15 +++++++- README.md | 2 +- book/guessing_game/Cargo.toml | 8 +++++ book/guessing_game/src/main.rs | 12 +++++++ book/hello_cargo/Cargo.toml | 8 +++++ book/hello_cargo/src/main.rs | 3 ++ book/notes | 60 ++++++++++++++++++++++++++++++++ book/url | 1 + class/desc | 62 ++++++++++++++++++++++++++++++++++ udemy_course | 3 ++ 10 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 book/guessing_game/Cargo.toml create mode 100644 book/guessing_game/src/main.rs create mode 100644 book/hello_cargo/Cargo.toml create mode 100644 book/hello_cargo/src/main.rs create mode 100644 book/notes create mode 100644 book/url create mode 100644 class/desc create mode 100644 udemy_course diff --git a/.gitignore b/.gitignore index e420ee4..6985cf1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,14 @@ -target/* +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb diff --git a/README.md b/README.md index 444a5aa..e50849e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # rust2 -notes for studying rust, 2nd time around \ No newline at end of file +notes for studying rust, 2nd time around diff --git a/book/guessing_game/Cargo.toml b/book/guessing_game/Cargo.toml new file mode 100644 index 0000000..78c94fe --- /dev/null +++ b/book/guessing_game/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "guessing_game" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/book/guessing_game/src/main.rs b/book/guessing_game/src/main.rs new file mode 100644 index 0000000..6320973 --- /dev/null +++ b/book/guessing_game/src/main.rs @@ -0,0 +1,12 @@ +use std::io; +// file:///home/luket/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/std/io/index.html + +fn main() { + println!("guess the number"); + println!("your guess: "); + let mut guess = String::new(); + io::stdin() + .read_line(&mut guess) + .expect("failed to read line"); + println!("your guess: {guess}"); +} diff --git a/book/hello_cargo/Cargo.toml b/book/hello_cargo/Cargo.toml new file mode 100644 index 0000000..19c7b36 --- /dev/null +++ b/book/hello_cargo/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "hello_cargo" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/book/hello_cargo/src/main.rs b/book/hello_cargo/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/book/hello_cargo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/book/notes b/book/notes new file mode 100644 index 0000000..c9d4aaf --- /dev/null +++ b/book/notes @@ -0,0 +1,60 @@ +chapter 2 +https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html + +include packages: + using std::io; + +print is a macro: + println!("text"); + +make a new mutable string: + let mut guess = String::new(); + // new is a function of the string type. + // an "associated function" + +& is a reference + +result is an enumeration +it's variants are "Ok" and "Err" + + +There are a set of "items" defined before importing anything. This is called the "prelude". + + +chapter 1 +https://doc.rust-lang.org/book/ch01-00-getting-started.html + +linux: + curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh + +update: + rustup update + +docs: + rustup doc + +compiler is `rustc` + +cargo --version + +toml = toms obvious minimal language + +new project: + cargo new $project_name --vcs=none + +$project_dir/ +$project_dir/Cargo.toml +$project_dir/src/main.rs +$project_dir/target/debug/$project_bin + +build: + cargo build + +run: + cargo run + +don't compile, just check: + cargo check + +don't add debug symbols: + cargo build --release diff --git a/book/url b/book/url new file mode 100644 index 0000000..123b0e3 --- /dev/null +++ b/book/url @@ -0,0 +1 @@ +https://doc.rust-lang.org/book/ diff --git a/class/desc b/class/desc new file mode 100644 index 0000000..5d80e08 --- /dev/null +++ b/class/desc @@ -0,0 +1,62 @@ +Overview +Prerequisite +The course is for Rust beginners: +You already know how to program, preferably in a statically typed language. +Some knowledge of C or C++ will be helpful since we'll sometimes compare Rust constructs with those languages. +You should not take the go/rust-101 course first since we will cover the same content, plus much more. +Description +Mailing list: g/comprehensive-rust +Chat: go/comprehensive-rust-chat +Material: go/comprehensive-rust-material +Recordings: go/comprehensive-rust-recordings +Repository: go/comprehensive-rust-repository +More: go/comprehensive-rust-classes +This Rust training is for people with no prior Rust experience. The course covers the core of Rust, from basic syntax to advanced topics such as traits, generics, error handling, and memory management. + +The course is split over three days, with each day covering increasingly advanced part of the language. + +Day 1: + +Basic syntax: tuples, structs, enums, and methods +Memory management, ownership, borrowing, and lifetimes +Exercises +Day 2: + +Control flow expressions +Pattern matching +Modules and project structure +Important standard library types +Exercises +Day 3: + +Traits and generics +Error handling +Testing +Unsafe Rust +Exercises +We have a number of other classes which cover more spezialized topics such as bare-metal Rust, concurrency, and Rust in Android. Please see go/comprehensive-rust-classes +. + + + +Please register your interest with the Session Alert in the bottom-right corner. Contact Martin Geisler + and Thomas Oertli + if you would like to schedule a class for your team or if you would like to teach a class yourself. Contact g/comprehensive-rust + and github.com/google/comprehensive-rust/discussions + with general questions. + + + +Pre-work +Please install the Rust compiler and the Cargo build system before the course. Follow the instructions on https://rustup.rs/ + for this. + +Check that everything worked by running + +$ cargo new my-project + +$ cd my-project + +$ cargo run + +If this completes successfully, you'll be all set for the course. diff --git a/udemy_course b/udemy_course new file mode 100644 index 0000000..599dc2a --- /dev/null +++ b/udemy_course @@ -0,0 +1,3 @@ +pass show study/udemy.com + +'ultimate rust'