Closed nsmryan closed 5 years ago
I've run into some situations where it would be nice to copy a Map struct, and there is no way to do this currently without calling ffi functions.
It seems like Map could impl Clone and call TCOD_map_copy to allow new maps a little more ergonomically.
I can make a pull request for this if you want. The code I came up with is:
impl Clone for Map { fn clone(&self) -> Self { let (width, height) = self.size(); let mut new_map = Map::new(width, height); unsafe { ffi::TCOD_map_copy(*self.as_native(), *new_map.as_native()); } new_map } }
That looks good to me! Yes please, if you put up a PR, I'd be happy to review it.
Closed via #285
I've run into some situations where it would be nice to copy a Map struct, and there is no way to do this currently without calling ffi functions.
It seems like Map could impl Clone and call TCOD_map_copy to allow new maps a little more ergonomically.
I can make a pull request for this if you want. The code I came up with is: