Hi. I have a struct called Cell and find() function inside of the Game.
Game struct has Vec<Cell> as it's field and find() function searches the position of the cell and return Option<Cell> as a cell might not be found.
I'm not really familiar with vector handling and so Im not so sure what i am doing right now.
I appreciate any help/advice :)
#[derive(PartialEq)]
pub struct Cell {
pub pos: (f32, f32),
}
impl FromIterator<Cell> for Cell {
fn collect<I: IntoIterator<Item = Cell>>(iter: I) -> Self {
//I'm not sure what im doing
}
}
pub fn find(&mut self, x: f32, y: f32) -> Option<Cell> {
let cell: Cell = self
.cells
.into_iter()
.filter(|&a| a.pos == (x, y))
.collect(); // here
if (x, y) == cell.pos {
Some(cell)
} else {
None
}
}