
Iterators & Closures
Iterator trait, iterator adapters (map, filter, fold), closure syntax, move closures, Fn traits
1Which trait must a type implement to be usable in a for loop in Rust?
Which trait must a type implement to be usable in a for loop in Rust?
Odpowiedź
The IntoIterator trait allows a type to be converted into an iterator. The for loop automatically calls into_iter() on the expression. Types like Vec, arrays and ranges implement this trait by default, which allows iterating over them directly with for.
2Which method of the Iterator trait must be implemented?
Which method of the Iterator trait must be implemented?
Odpowiedź
The next() method is the only required method of the Iterator trait. It returns Option<Self::Item>, either Some(item) if there are remaining elements, or None when iteration is complete. All other methods like map, filter or collect have default implementations based on next().
3What is the difference between iter(), iter_mut() and into_iter() on a Vec<T>?
What is the difference between iter(), iter_mut() and into_iter() on a Vec<T>?
Odpowiedź
iter() returns an iterator over immutable references (&T), iter_mut() over mutable references (&mut T), and into_iter() consumes the Vec and returns elements by value (T). The choice depends on whether you want to read, modify or take ownership of the elements.
What is a lazy iterator in Rust and why is it important?
What is the correct syntax to define a closure that takes two i32 parameters and returns their sum?
+19 pytań z rozmów
Inne tematy rekrutacyjne Rust
Rust Basics
Ownership & Borrowing
Structs & Enums
Error Handling
Collections
Modules & Packages
Traits
Generics
Lifetimes
Smart Pointers
Concurrency Basics
async/await
Testing
Cargo & Ecosystem
Pattern Matching
Macros
Serde & Serialization
Unsafe Rust
Advanced Traits
Advanced Lifetimes
Type System
Tokio & Async I/O
Performance Optimization
Memory Management
Web Frameworks
Database Integration
Rust Design Patterns
Opanuj Rust na następną rozmowę
Uzyskaj dostęp do wszystkich pytań, flashcards, testów technicznych, ćwiczeń code review i symulatorów rozmów.
Zacznij za darmo