Это видео недоступно.
Сожалеем об этом.
Peek and Peekable | Rust Language
HTML-код
- Опубликовано: 23 май 2024
- Using peek() allows you to inspect the next element without consuming it, giving you the flexibility to make decisions based on future elements before advancing the iterator. I show some code and refer to an example which uses peek to check for EOF.
Note : when you call methods that consume the iterator, such as next(), collect(), or for loops, the iterator itself needs to be mutable.
e.g. let mut iter = config_lines.iter().peekable();
---
Sources : I've used Official Rust docs, "Rust in a month of lunches" book (Dave Macleoad), and chatGPT!
Code example 1 :
🟩 play.rust-lang.org/?version=s...
Code example 2 :
🟩 play.rust-lang.org/?version=s...
#rustprogramming #Peek #rusttutorial