Idiomatic Rust - Iterating over Option

Idiomatic Rust - Iterating over Option

Let's Get Rusty

2 года назад

24,075 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@markday3145
@markday3145 - 06.04.2022 16:42

That was really educational. Thanks! I really liked using extend on the optional.

I think it would have been easier to understand if you started with just iterating over the optional before combining that with other things. For example:

println!("Some variant:");
let mut optional_grade = Some("A+");
for grade in optional_grade {
println!("{}", grade);
}

println!("None variant:");
optional_grade = None;
for grade in optional_grade {
println!("{}", grade);
}

println!("Done.");

Ответить
@WolvericCatkin
@WolvericCatkin - 06.04.2022 17:07

I think `std::iter::once()` would've been interesting, given it effectively wraps the passed value in an `Option<T>`, and calls `.into_iter()` on it, when the `.next()` method is called on the returned iterator...

Ответить
@inx1819
@inx1819 - 06.04.2022 17:13

I'm looking forward to your videos every day. Keep the incredible work up!

Ответить
@jonathanmoore5619
@jonathanmoore5619 - 06.04.2022 17:14

Great video. Is that new syntax (grades:?). Must have missed that.

Ответить
@austineumenesi3602
@austineumenesi3602 - 06.04.2022 18:02

I think a good idea for a topic would be to discuss common structures used to avoid complicated ownership issues as people new to Rust encounter this problem regularly. An example of something I see often is when two objects need to reference each other it's common to use ids to reference each other rather than use the actual underlying object so instead of having a Library contain a Vec<Book> you will instead see a Library have a Vec<BookId> and then any actual data can be accessed via some kind of Map based lookup

Ответить
@meka4996
@meka4996 - 06.04.2022 18:04

Super! Thank you

Ответить
@jasonlantz3808
@jasonlantz3808 - 06.04.2022 18:38

comment...

Ответить
@payman5581
@payman5581 - 06.04.2022 19:01

Keep up the good work.

Ответить
@luizneri
@luizneri - 06.04.2022 20:12

whats difference between iter() into_iter()?

Ответить
@jrmoulton
@jrmoulton - 07.04.2022 01:37

This one was great!

Ответить
@jaspereijkenboom4716
@jaspereijkenboom4716 - 07.04.2022 02:23

I really like this!

Ответить
@ringo.gg.
@ringo.gg. - 07.04.2022 03:58

Nice video man!

Ответить
@codetothemoon
@codetothemoon - 07.04.2022 06:54

Cool!

Ответить
@flogginga_dead_horse4022
@flogginga_dead_horse4022 - 07.04.2022 06:59

my head exploded

Ответить
@bjugdbjk
@bjugdbjk - 07.04.2022 12:42

Dedicated playlist on Concurrency pls !! ur teaching skills r amazing, I have gone through the concurrency videos in your rust book playlist , the way you explained the concurrency is fantastic, you made it look so simple !! A dedicated playlist covering topics deadlocks mitigation strategies, sync,send,async & await will be a huge help for rust community !! Waiting for it ...

Ответить
@primingdotdev
@primingdotdev - 07.04.2022 13:51

This new series is the best yet, maybe a videos where you do wider refactors applying the concepts here would be useful.

Ответить
@runescapefreedownload
@runescapefreedownload - 08.04.2022 07:44

Love this series so much

Ответить
@ZachariahCavazos
@ZachariahCavazos - 13.04.2022 14:46

great stuff. very practical 🎉🎉

Ответить
@zaspanyflegmatyk2446
@zaspanyflegmatyk2446 - 19.04.2022 01:12

i love your vids, but in general I think you should try to use more graphical examples, like you know, drawing pointers in paint etc. That would really help

Ответить
@SpeedingFlare
@SpeedingFlare - 19.04.2022 20:12

OMG I literally just did if let some push yesterday. There's so much I don't know yet

Ответить
@goodwish1543
@goodwish1543 - 24.04.2022 08:55

Super clean and concise! Thanks.

Ответить
@jackkendall6420
@jackkendall6420 - 27.04.2022 09:56

Great video, all killer no filler. I'm going to watch some of your other videos and probably subscribe.

Ответить
@lukejagodzinski
@lukejagodzinski - 03.05.2022 01:03

As I really enjoy your content, here I wonder if less code is actually better. Code is supposed to be read by other developers and should be self explanatory without writing any comments. Maybe more experienced Rust developers will not have problem with reading such constructs but for others it might be tough if there is some "magic" happening behind the scenes. For example in JS sometimes it's better to write a simple for loop than use a reduce function, sometimes it's better to be just more explicit. But maybe I'm wrong.

Ответить
@Musikur
@Musikur - 04.05.2022 07:53

What would you have needed to do to do the opposite to the last one, keep only the strings at the end? Also, I didn't realise yo ucould use the template strings like that in rust!

Ответить
@_jdfx
@_jdfx - 03.07.2022 09:35

I really like this format, simple and powerful functions explained clearly and fast. Great stuff!

Ответить
@porky1118
@porky1118 - 22.07.2022 01:34

This type information in your editor is just confusing.
Especially the one, that's not valid rust.
A newbie might think, it's necessary to add the type info.

Ответить
@raffimolero64
@raffimolero64 - 01.08.2022 13:55

Never would've thought of using flatten on an iterator over options. Very educational.

Ответить
@linmartin1841
@linmartin1841 - 17.09.2022 11:17

Clean and concise!!! Can't wait to see your new videos : )

Ответить
@blazingazong
@blazingazong - 28.12.2022 09:52

This was one of those videos where I just had to keep taking screenshots. I really enjoy getting to see all of rust’s obscure methods and how they can be chained into single line expressions that perform multiple lines of code worth of operations

Ответить
@hamzamohd.zubair1709
@hamzamohd.zubair1709 - 28.05.2023 09:54

please make more of idiomatic rust

Ответить
@kennethdashensheridan6906
@kennethdashensheridan6906 - 05.03.2024 21:14

My brain…it hurts lol

Ответить
@Im_Ninooo
@Im_Ninooo - 13.05.2024 07:36

this is beautiful

Ответить