Rust's Most Important Containers 📦 10 Useful Patterns

preview_player
Показать описание
A walkthrough and explanation of 10 useful patterns involving Rust's Option and Result containers.



Stuff I use to make these videos - I absolutely love all of these products. Using these links is an easy way to support the channel, thank you so much if you do so!!!

Рекомендации по теме
Комментарии
Автор

The complexity progression through the video is super helpful, great format, you should do more like this one.

gdnight
Автор

My first exposure to Results and Options were at my internship where I was writing C# based on the railway-oriented programming paradigm. My goodness, I love not dealing or worrying about nulls, and Rust handles this form of error handling so beautifully.

theuberlord
Автор

So helpful - I've seen all these variants in code (I'm a beginner) but couldn't keep them straight in my head. Seeing you build them up from ground level straightened it out for me. Thank you!

richardlyon
Автор

Wow. Great video! It gave me new tools to handle errors aside from 'match' and 'if let' It certainly will improve my future code readability. Thank you!

yumbuboyumbubo
Автор

This really helped me a lot. the functions and containers are so similar it's nice to have a run through these patterns.

aussieexpat
Автор

In that use case, you can use .or(SummationError) instead of .map_err(|_| SummationError) method.

oglothenerd
Автор

Thank me so much for helping me through handling errors in Rust. You deepened my knowledge 🙌

bibiertifwehgweifhgiwe
Автор

Each video I watch from this channel makes me less angry with Rust. 🤝

NeatMemesDotCom
Автор

It would be nice if those 10 patterns got indexed or simply numbered in the video :)

jambangpisang
Автор

Wow, that was a useful video compressed in a few minutes. Thanks!

datag
Автор

This is a great video! The example and the explanation done extremely well! I like how you explain hard things.

platoek
Автор

Really great video about the subject. Thanks a lot!!!

Автор

First of all, thanks for sharing this content. I'm a C++ coder, highly interested in Rust. Very helpful stuff. What I don't get at first glance is: When an error happens and we have a Result as a return value, is the error returned instantly without needing to explicitly "return" it? Does Rust handle this for us? Because I would expect to do things like "return None, Error" in terms of pseudocode.

geforcefan
Автор

3:22 missed meme opportunity with explosion, confetti, children "yay" and hysterically blinking colourful text "welcome to runtime"

Randych
Автор

that was great! This is exactly something I struggled with as a Rust beginner but coming from other languages.

Teflora
Автор

I just learned more rust in 15 minutes than a few hours of "tours"

nomadtrails
Автор

Great video! Really good and understandable structure.

mivoe
Автор

Video cheatsheet so you don't repeat watching (although enjoyable and dense)
behaviour required @ None/Error ==> pattern used.

stop entire program ==> .unwrap()
stop entire program with custom message ==> .expect("message")

stop current function and return None/Error ==> ?

extract the value if it exists else use a default value ==> .unwrap_or(default_value)
extract the value if it exists or get it from a function ==> .unwrap_or_else(|| function())
do something if there is a value and move on otherwise ==> if let
do something if there is a value and do something else otherwise ==> match


Wrap in Result or Option container?
If you want to let the caller function understand what went wrong, use Result, otherwise Option.

Use .ok and its variants to convert between the two as required.

AhmedIsam
Автор

I've programmed c# for over 15 years, and rust only outside of work. I love your explainations of what's happening in rust.

catsgotmytongue
Автор

rust: ah take these 2 enums and have fun
dev: yay seems simple.very clean. what could go wrong
also dev: every day head banging between these 100s of inter conversion functions "matching" them to the "expected" situations

😵‍💫

muhammadharris