Crust of Rust: Iterators
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.
You can find the final code at https://gist.github.com/jonhoo/dd63b720fa4a220ea845a77e2d75831e.
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
You can watch the live version with comments at https://www.youtube.com/watch?v=pqHWEsXamYg
Видео Crust of Rust: Iterators канала Jon Gjengset
You can find the final code at https://gist.github.com/jonhoo/dd63b720fa4a220ea845a77e2d75831e.
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
You can watch the live version with comments at https://www.youtube.com/watch?v=pqHWEsXamYg
Видео Crust of Rust: Iterators канала Jon Gjengset
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Crust of Rust: Smart Pointers and Interior MutabilityThesis: Partial State in Dataflow-Based Materialized ViewsCreating a Chat Server with async Rust and TokioIterators - RustRust at speed — building a fast concurrent databasePascal Hertleif - Writing Idiomatic Libraries in RustLet's Learn Rust: Structs and TraitsDesktop and editor setup for Rust developmentGothamGo 2017: Closures are the Generics of Go by Jon BodnerLive-coding a linked hash map in RustRust NYC: Jon Gjengset - Demystifying unsafe codeCrust of Rust: Subtyping and VarianceProcedural Macros in Rust (part 1)Declarative Programming in RustIntro to Rust-lang (Concurrency, Threads, Channels, Mutex and Arc)Crust of Rust: Atomics and Memory OrderingCrust of Rust: Lifetime AnnotationsYOW! Lambda Jam 2019 - Amit Dev - Introduction to Functional Programming in RustRust Cologne: A generalist's view of traitsDynamic vs Static Dispatch in Rust