Skip to content

Instantly share code, notes, and snippets.

View max-itzpapalotl's full-sized avatar

max-itzpapalotl

View GitHub Profile
@max-itzpapalotl
max-itzpapalotl / 002functions.md
Last active January 6, 2024 13:12
2. Functions and Arguments

2. Functions in Rust

Content:

  • Function, no args, calling it.
  • One string argument, default move, not usable any more after move.
  • Immutable ref, can have multiple.
  • Mutable ref, can only have one.
  • Return values, default move.
  • Cannot return reference -> life time tracking.
@max-itzpapalotl
max-itzpapalotl / why.md
Last active January 6, 2024 13:12
0. Why am I making these videos?

0. Why am I making "Rust = Future<C++>" videos?

  • Welcome, my name is Max.
  • I would like to help you to switch from C++ to Rust programming.
  • I believe that the future of C++ programming is Rust.
  • I always wanted to invent a programming language. Then I found Rust.
  • I like Rust and find that I am very productive with it, after a short amount of time.
  • I want to help people to learn Rust.
  • Target audience: People, who already know C++ and know how to program.
@max-itzpapalotl
max-itzpapalotl / getting_started_rust_linux.md
Last active January 6, 2024 13:12
1. Getting started with Rust on Linux with vim

1. Getting started with Rust on Linux with vim

Installing Rust with rustup

URL: https://rustup.rs/

Do this command:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
@max-itzpapalotl
max-itzpapalotl / basic_types.md
Last active January 6, 2024 13:12
3. Basic data types in Rust

3. Basic data types in Rust

  • integers, signed and unsigned
  • floats
  • bool
  • char
  • std::mem::size_of
  • String and &str
  • arithmetic: only same types
  • casting with "as"
@max-itzpapalotl
max-itzpapalotl / strings.md
Last active January 6, 2024 13:12
4. Strings and String Slices

4. Strings and String Slices

  • String vs. &String vs. &str vs. str
  • String constants
  • Converting between strings and slices
  • Taking a slice of a string
  • Byte slices
  • Conversion to strings
  • Unsafe but fast
  • Function arguments: prefer &str over &String
@max-itzpapalotl
max-itzpapalotl / tuples_arrays.md
Last active January 6, 2024 13:13
5. Compound types: tuples and arrays

5. Compound types: tuples and arrays

  • Tuple type and syntax of tuples
  • Printing
  • Tuples as argument types, access to components
  • Tuples as return values
  • Destructuring tuples
  • Array type and array syntax
  • Printing
  • Bounds checking at compile time
@max-itzpapalotl
max-itzpapalotl / structs_methods.md
Last active January 7, 2024 12:34
6. Structs and Methods

6. Structs and Methods

  • Struct types
  • Tuple Structs
  • Methods and their use
  • Private and public data, access rules

Struct definitions

@max-itzpapalotl
max-itzpapalotl / vectors.md
Last active January 6, 2024 13:13
7. Vectors

7. Vectors

  • Constructing and accessing
  • Element access and bounds checking
  • The vec! macro
  • Iterating over a vector
  • Slices of vectors

Constructing and accessing

@max-itzpapalotl
max-itzpapalotl / hashmaps.md
Last active January 7, 2024 12:35
8. HashMaps

8. HashMaps

  • Construction, insertion
  • Lookup, deletion
  • Matching
  • HashMap literals

Construction, insertion

@max-itzpapalotl
max-itzpapalotl / enums.md
Last active January 8, 2024 17:43
9. Enums, algebraic types and matching

9. Enums, algebraic types and matching

  • Simple enums, construction, handling
  • Enums as tagged variants, construction, handling
  • Enum arguments
  • Matching and destruction
  • Methods for enums

Simple enums