What a heck
pub fn get_chunk(&mut self, position: Point<i32>) -> &mut Chunk {
if self.chunks.contains_key(&(position.x, position.y)) {
return self.chunks.get_mut(&(position.x, position.y)).unwrap();
}
let chunk = self.generate_chunk(position);
self.chunks.insert((position.x, position.y), chunk);
return self.chunks.get_mut(&(position.x, position.y)).unwrap();
}
it works
I got why it didn't work, but it's painful after other programming languages...
Especially I'm getting disappointed by this part:
let chunk = self.generate_chunk(position);
self.chunks.insert((position.x, position.y), chunk);
return self.chunks.get_mut(&(position.x, position.y)).unwrap();