All Questions
5 questions
5
votes
1
answer
2k
views
Access iterator inside its for loop
I am testing a custom bi-directional iterator in rust but i ran into error
error[E0382]: borrow of moved value: `iter`
--> src/main.rs:40:13
|
37 | let mut iter = BiIterator::from(vec![...
-1
votes
1
answer
516
views
Wrong answer on kattis problem: texture analysis
I recently tried to do the online programming challenge Texture Analysis on open.kattis.com; however, despite my answers for the sample cases being correct in my personal tests, I keep getting the ...
-1
votes
1
answer
103
views
More techniques for recursive patterns in iteration
Building on Techniques for turning recursive functions into iterators in Rust?, I'd like to explore the challenges of iterators.
Let's think about a recursive yield-based function with slightly more ...
1
vote
1
answer
1k
views
How do I implement a non-consuming IntoIterator for a struct with an underlying collection?
Let's say I have a struct that has a collection, such as a Vec as one of its data members:
struct MyCollection {
data: Vec<i32>
}
I want the user of MyCollection to be able to iterate over ...
10
votes
2
answers
3k
views
Conditionally return empty iterator from flat_map
Given this definition for foo:
let foo = vec![vec![1, 2, 3], vec![4, 5, 6], vec![7, 8, 9]];
I'd like to be able to write code like this:
let result: Vec<_> = foo.iter()
.enumerate()
....