diff --git a/courses/IntroToRust/.gitignore b/courses/IntroToRust/.gitignore new file mode 100644 index 0000000..53c37a1 --- /dev/null +++ b/courses/IntroToRust/.gitignore @@ -0,0 +1 @@ +dist \ No newline at end of file diff --git a/courses/IntroToRust/README.md b/courses/IntroToRust/README.md new file mode 100644 index 0000000..678505d --- /dev/null +++ b/courses/IntroToRust/README.md @@ -0,0 +1,3 @@ +# RustSeminar +Introduction to Rust with Reese Hatfield via OSEDA.net + diff --git a/courses/IntroToRust/css/custom.css b/courses/IntroToRust/css/custom.css new file mode 100644 index 0000000..5136329 --- /dev/null +++ b/courses/IntroToRust/css/custom.css @@ -0,0 +1,115 @@ + +/* sensible styles */ +.reveal section { + font-family: "Arial", sans-serif; +} + +.reveal h1 { + color: #f92672; + text-align: left; + margin: 0 0 0.5em 0; + line-height: 1.2; +} + +.reveal h2 { + text-align: left; +} + + +.left { + text-align: left; +} + + +.horizontal-container { + display: flex; + justify-content: space-between; + align-items: center; + gap: 2em; +} + +.vertical-container { + display: flex; + flex-direction: column; + justify-content: space-between; + align-items: flex-start; + gap: 20pt; +} + +.center-container { + display: flex; + justify-content: center; + align-items: center; +} + +.left { + text-align: left; +} + +/* general slide layout for all sections */ +.reveal .slides section { + display: flex !important; + flex-direction: column; + justify-content: flex-start; + align-items: stretch; + gap: 1em; + padding-top: 2em; + box-sizing: border-box; +} + +.horizontal-container .text { + flex: 1; +} + +.horizontal-container .image { + flex: 1; + max-width: 45%; + height: auto; + object-fit: contain; +} + +.reveal ul { + text-align: left; + margin: -1em 0 0 0; + padding-left: 1.2em; +} + +.reveal .slides section.center-slide { + display: flex !important; + flex-direction: column; + justify-content: center; + align-items: center; + min-height: 100vh; + text-align: center !important; + gap: 1em; +} + +.center-slide h1 { + margin: -1.7em 0 0 0; +} + +.reveal pre.full-code, +.reveal pre.full-code code { + max-height: none !important; + overflow: visible !important; + white-space: pre !important; +} + +.no-wrap { + white-space: nowrap; +} + +.move-up-1 { + margin: -1em 0 0 0 !important; +} + +.move-up-2 { + margin: -2em 0 0 0 !important; +} + +.move-up-3 { + margin: -3em 0 0 0 !important; +} +.move-up-4 { + margin: -4em 0 0 0 !important; +} \ No newline at end of file diff --git a/courses/IntroToRust/index.html b/courses/IntroToRust/index.html new file mode 100644 index 0000000..dab5b1c --- /dev/null +++ b/courses/IntroToRust/index.html @@ -0,0 +1,14 @@ + + +
+ +
+
+
+
+
+
+
+
+ const arr = ["alice", "bob", "charlie"];
+console.log(arr[5])
+ Undefined
+
+ arr = ["alice", "bob", "charlie"]
+x = arr(5)
+ Index exceeds the number of array elements.
+Index must not exceed 3.
+Error in file (line 2)
+x = arr(5);
+
+ cargo initcargo run
+ fn main() {
+ let greeting = "Hello, world!";
+ println!("{}", greeting);
+}
+letstdout
+fn main() {
+ let arr = ["alice", "bob", "charlie"];
+ let x = arr[5];
+}
+
+
+
+
+ fn main() {
+ let x = 5;
+ x += 1;
+}
+
+
+ fn main() {
+ let mut x = 5;
+ x += 1;
+}
+
+
+
+ NULL
+
+ enum Direction {
+ North,
+ South,
+ East,
+ West,
+}
+
+
+ struct Color{
+ r: bool,
+ g: bool,
+ b: bool,
+}
+
+let black = Color { r: false, g: false, b: false };
+let blue = Color { r: false, g: false, b: true };
+let white = Color { r: true, g: true, b: true };
+
+ match keyword
+ let x = match get_direction() {
+ Direction::North => 1,
+ Direction::East => 2,
+ Direction::South => 3,
+};
+
+
+
+
+let x = match get_direction() {
+ Direction::North => 1,
+ Direction::East => 2,
+ Direction::South => 3,
+ Direction::West => 4
+};
+
+
+ struct FakeCat {
+ alive: bool,
+ hungry: bool,
+}
+
+
+ enum RealCat {
+ Alive { hungry: bool },
+ Dead,
+}
+
+ let status = match getCat() {
+ RealCat::Alive { hungry: true } => "Feed me!",
+ RealCat::Alive { hungry: false } => "Doing great",
+ RealCat::Dead => ":(",
+}
+
+ Option TypeSome(T) or Nonepub enum Option<T> {
+ None,
+ Some(T),
+}
+fn find_user_id(name: &str) -> Option<i32> {
+ // or return Some(user)
+ return None;
+}
+fn main() {
+ match find_user_id("Alice") {
+ Some(id) => println!("Found user with id {id}"),
+ None => println!("User not found"),
+ }
+}
+ Result TypeOk(T) or Err(T)enum Result<T, E> {
+ Ok(T),
+ Err(E),
+}
+fn divide(a: i32, b: i32) -> Result<i32, String> {
+ if b == 0 {
+ return Err("cannot divide by zero".to_string());
+ }
+ Ok(a / b)
+}
+
+fn main() {
+ let x = match divide(10, 2) {
+ Ok(result) => result * 2,
+ Err(err) => 0,
+ };
+}
+fn divide(a: i32, b: i32) -> Result<i32, String> {
+ if b == 0 {
+ return Err("cannot divide by zero".to_string());
+ }
+ return Ok(a / b);
+}
+
+fn do_math() -> Result<i32, String> {
+ let temp = divide(15, 3)?;
+ return Ok(temp);
+}
+
+
+ free()
+ fn greet(name: String) {
+ println!("Hello, {}!", name);
+}
+
+fn main() {
+ let name = String::from("Bob");
+
+ greet(name);
+
+ println!("You greeted {}", name);
+}
+
+
+ fn greet(name: &String) {
+ println!("Hello, {}!", name);
+}
+
+fn main() {
+ let name = String::from("Bob");
+
+ greet(&name);
+
+ println!("You greeted {}", name);
+}
+
+ fn greet(name: &String) {
+
+ name = &name.to_uppercase();
+ println!("Hello, {}!", name);
+}
+
+fn main() {
+ let name = String::from("Bob");
+
+ greet(&name);
+
+ println!("You greeted {}", name);
+}
+
+ fn greet(name: &mut String) {
+ *name = name.to_uppercase();
+ println!("Hello, {}!", name);
+}
+
+fn main() {
+ let mut name = String::from("Bob");
+ greet(&mut name);
+ println!("You greeted {}", name);
+}
+
+
+ println!, vec!, format!
+ macro_rules! say_hello {
+ () => {
+ println!("Hello, world!");
+ };
+}
+
+fn main() {
+ say_hello!();
+}
+ fn main() {
+ let names = vec!("Alice", "Bob", "Charlie");
+
+ let x = true;
+ assert!(x, "x wasn't true!");
+
+ println!("{:?}", names);
+}
+
+
+
+ [package]
+name = "IntroToRust"
+version = "0.1.0"
+edition = "2021"
+authors = ["Reese Hatfield <reese@example.com>"]
+description = "Introductory Rust code snippets"
+license = "MIT"
+
+[dependencies]
+rand = "0.8"
+chrono = "0.4"
+
+
+
+
+
+