Crust of Rust: Iterators

preview_player
Показать описание
In this third Crust of Rust video, we cover iterators and trait bounds, by re-implementing the "flatten" Iterator method from the standard library. As part of that, we cover some of the weirder trait bounds that are required, including what's needed to extend the implementation to support backwards iteration.

0:00:00 Introduction
0:01:45 The Iterator trait
0:04:25 The IntoIterator trait
0:06:24 Generic traits vs associated types
0:13:37 Provided Iterator methods
0:14:42 Iterator::flatten
0:20:07 Associated items of generics in bounds
0:23:10 Why must O as Trait be bracketed?
0:24:28 Flattening more than two levels
0:25:24 First attempt at Flatten::next
0:29:59 Two elements in inner iterator
0:31:05 Two elements in outer iterator
0:33:29 Simplifying with ?
0:35:05 Storing the inner iterator
0:39:10 Trait bound syntax
0:40:07 Finishing corrected next
0:42:50 Ergonomics with IntoIterator
0:44:15 DoubleEndedIterator
0:46:10 First draft of DEI implementation
0:50:57 Testing double-ended iteration
0:53:58 Iterating from both ends in parallel
1:04:02 The cost of two cursors
1:06:28 Iterators are like Futures
1:07:14 Calling next and next_back concurrently
1:07:55 ref in patterns
1:09:33 Why not flatten first, then iterate
1:12:51 More ref in patterns
1:14:09 Deeper flattening
1:17:00 FlatMap
1:18:19 Ergonomics through extension traits
1:21:19 Sized in traits

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

As a Rust beginner, I find your videos invaluable. Thank you Jon !!

howardmarles
Автор

I love that your inclination is to show the correct use first. So many programmers preface their guides with the wrong way first and it makes me rage

jeremycoleman
Автор

I just learnt iterator design pattern and now this, was super relatable.

vroomerlifts
Автор

I am so, so, so tired of writing javascript and python. The most complicated thing I do all day is refactor crapping javascript formatting and try to convince people to follow better eslint rules, learn yet another annoying new npm package that probably has way to many dependencies, or have to constantly keep CTRL-F 'ing through a crappy python function that is 100 lines long. I am ready for Rust. Let's go!!
Great video. Great explanation. Thank you so much 🙏

jackmead
Автор

10:00 into_iter takes the ownership of the value, which is the meaning of "into", the ownership is transfered "into" the iterator. value.into_iter() makes sense this way :)

vorname
Автор

this is the best rust content produced, ever. Most rust devs or wannabes have programmed a computer before so will quickly get tired of "from zero" tutorials

connormatza
Автор

Really enjoying these Crust of Rust videos. The more lengthy videos are interesting, but I often feel lost halfway through. The shorter ones feel more relevant when you're still learning the basics but have gotten through the book.

fredrikjonsen
Автор

I am learning so much from you. Working with rust code from your streams and going from (kind of getting it) to (okay I actually GET it) feels oddly satisfying, and I have never felt like this while learning other languages over the years.

Mahmudul_Hasan
Автор

Thank you Jon for all these learning materials. This is definitely helpful. I'm going through the whole crust of rust series and then I'll go through your book as well. I already book the pre-release. 💪😁

jonas-mmem
Автор

Perfect presentation, I look forward to following your series as more presentations are made!

KiffinGish
Автор

Thank you for the video! I have used iterators in other languages such as java and I am fairly familiar with the concept. But I still found your explanation useful.

abdulazizalabodi
Автор

Thank you so much for these series. Really happy to see these type of videos about advanced Rust topics.

wvanmourik
Автор

Thank you for these videos! Very helpfull!

Tantandev
Автор

This is the next rust video I've watched

unspecifiedsender
Автор

I'm leaning rust but... but one things I've started to notice (especially in this video ) is how crucial testing is and how rust makes it easy to encourage you to write them...

brod
Автор

It's so great about how to think and try to implement by self to learn. By the way, is there any vim/nvim config in the video? It is good to have such lint related info or error show up. Thanks

AryungChen
Автор

76K views should equal 76K likes. The value in this man's content is incomprehensible, in my opinion(s).

damickillah
Автор

Hey, can you put together a stream for the topic Smart pointers? I personally read the book about 2-3 times and still don't get the Cell and RefCell pointers.

kurjak
Автор

omg! That is crazy man! Jeg elsker det

ramazangCoder
Автор

9:58 iter and into_iter are 2 different things, aren't they? Iter is "read-only access" and into_iter is "consuming access"
In what way do they do same thing?

NoNameAtAll