Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Reusable/borrowed buffer within an `Iterator`
Have been trying to convert a (seemingly) straightforward loop
:
let mut input = Input::new();
loop {
// fn read_line(&mut self) -> &str
let line = input.read_line();
if !line.is_empty() { ... }
}
Into an Iterator
to opt into a for line in input { ... }
.
The simplest/most intuitive way about it seems to (necessarily) involve unsafe
.
The closest safest alternative, on the other hand, appears to involve GATs and wrappers and lending iterators and god knows what else. Is there any safe alternative for this particular case?
2 posts - 2 participants
🏷️ Rust_feed