Programming in Rust: Enums, Tagged Unions, Memory Layout and Pattern Matching

preview_player
Показать описание
Continuing in the short series on beginner's guide to programming in rust, we cover if enums and match expression logic in Rust. This video will show you the underlying memory representation of an enum, how it corresponds to type theory tagged unions. We will also cover the use of match expressions and pattern matching on variations of enums and values. I take a look at the Option enum and the use of null pointer optimization and how it is implemented with generics. Finally, I run through various examples that have been built in this channel such as a calculator, the http server, routers, binary search trees and a number of other examples that make use of enums and pattern matching. Be sure to check out a number of programming exercises in this channel for more examples!

↠ References:

Cheers! 🍻

🦀 #rust #rustlang #rustprogramming #exercises #programming
Рекомендации по теме
Комментарии
Автор

Thomas, thank you. Yet another fantastic video of Rust. The way you explain the inner-workings of this language is perfect for me. Recently, I started to learn to program. After being inundated by an ocean of tutorials online, it seemed that Python was the way to start coding, however, I discovered Rust... This put the brakes on the snake (python) and I dove deep into the rabbit-hole of Rust. This is not the language for beginners but I don't care about the learning-curve because Rust just makes sense to me: minimal runtime, memory safety, 'C' bindings, pattern matching, and threads without data races. The best part of your content is that you explain things in a simple manner. Most videos are tailored to programmers with experience. Hopefully this comment will be inspiration for you to keep doing what you are doing.

topcivilian
Автор

Hello, very good videos by the way!
But your example at 4:17 is broken. (compiler error)

You are writing :
let operator =

but this should be
let operator = Token::Op(Operator::Add);

Token::Operartor does not exist ;-)

toolbx_
Автор

Another mistake is saying a char is 4 bytes because of UTF-8. In Rust, strings are UTF-8 but individual chars are UTF-32. A string in Rust is *not* stored as a series of chars, though if you iterate over it the iterator will return chars to you, decoded from the UTF-8.

peter
Автор

that another fantastic video in rust thanks!, ,,, can you tell us how make vim like yours !

ajf
Автор

What program do you use to make your diagrams?

bigtymer