-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TileStorage::drain
and return removed entities in remove
#586
Conversation
Co-authored-by: Rob Parrett <[email protected]>
/// | ||
/// Panics if the given `tile_pos` doesn't lie within the extents of the underlying tile map. | ||
pub fn remove(&mut self, tile_pos: &TilePos) { | ||
self.tiles[tile_pos.to_index(&self.size)].take(); | ||
pub fn remove(&mut self, tile_pos: &TilePos) -> Option<Entity> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we get rid of this entirely and make checked_remove
the new remove
while we're adding a return value? 0.16 is going to come with fallible systems too, and I can't actually think of a use case for panicking here. Its not chainable, so .unwrap() won't add length to chains of calls if panicing is preferred.
upstream preference seems to be for returned errors, especially in cases of lesser-used apis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense.
The whole set of methods could really use a closer look though. Maybe I should revert the remove
changes and we can discuss in a separate issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to revert, but happy to discuss more generally in a separate issue. Even if we do that sort of thing the function signatures here will match and the only difference will be "no panic".
Fixes #579
I was tempted to call this
remove_all
instead to remove a potential source of confusion about what is happening to the underlying storage. Still on the fence about this, so let me know what you think.