Closed
Description
For example, this code:
fn main() {
let stream = "Hello, world!".chars().cycle();
for _ in range(0u, 10) {
let chunk: String = stream.take(3).collect();
println!("{}", chunk);
}
}
compiles and prints Hel
ten times, rather than the expected Hel
, lo,
, wo
, etc.
The fact that stream
isn't mut
is a clue that this code doesn't work as expected.
I guess the solution is stream.as_ref().take(3)
but the "default" behavior here is really confusing.
Metadata
Metadata
Assignees
Labels
No labels