Part of the Rust Crash Course: https://www.youtube.com/playlist?list=PL6yRaaP0WPkWRsXJgdnw9lj1vchAaKwfS
Welcome to the Rust Crash Course
In this course, we will be learning Rust from scratch. This course is very fast paced and designed for programmers who already have some experience with another programming language such as Dart or JavaScript or Swift. We will talk about variables, constants, ownership, functions, structures, enumerations, collections such as tuples, vectors, hash-maps and iterators, optionals, error handling, lifetime specifiers, traits, pointers, generics, packages, crates, modules and paths, asynchronous programming and we will also create 2 sample applications using Rust to put all these concepts to use!
In this chapter we are going to look at creating structures. Rust doesn't have classes unlike some other languages such as Dart or Swift. Instead, we use structures and traits. In this chapter, we will focus on creating structures and see why they are so useful!
Timestamps:
00:00 - Structures
00:06 - Structures allow you to name related values
01:05 - Rust used to have classes
01:41 - Create a simple Person struct with name and age
03:17 - Instantiate Person
04:41 - Accessing struct members with dot-notation
05:38 - Field init shorthand
07:38 - Struct update syntax
10:44 - Tuple structs
11:15 - Tuple struct for a 3D point
12:21 - Instantiating tuple structs
13:04 - Accessing tuple struct fields
14:05 - Implementations for structs
15:04 - Add "describe" function to Point in impl
17:17 - Add a "twice" function to Point in impl
18:34 - Add a mutating "make_twice" function to Point
20:18 - Debugging a custom struct
21:46 - Add "Debug" trait to Point
24:07 - Create mutable and immutable Point instances
25:45 - Associated functions with "self" are methods
25:59 - Non-method associated functions
26:27 - Add a non-method associated function to Point
27:34 - Calling non-method associated functions
28:05 - Multiple implementations
29:26 - Structs are the primary way of grouping data
If you want to support my work, please consider joining my YouTube channel by pressing the Join button!
Twitter: https://twitter.com/vandadnp
LinkedIn: https://linkedin.com/in/vandadnp
Let's get started!