Skip to content

Commit

Permalink
cleaner return
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf authored and cart committed Nov 15, 2020
1 parent 17c8786 commit bcdf30d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/bevy_ecs/hecs/src/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,9 @@ impl World {
let to_remove = T::with_static_ids(|ids| ids.iter().copied().collect::<HashSet<_>>());

match self.remove_bundle_internal::<_, T>(entity, to_remove, true) {
Ok(bundle) => Ok(bundle),
Ok(Some(bundle)) => Ok(bundle),
Err(err) => Err(err),
Ok(None) => unreachable!(),
}
}

Expand All @@ -685,7 +686,7 @@ impl World {
entity: Entity,
to_remove: std::collections::HashSet<TypeId, S>,
check_presence: bool,
) -> Result<T, ComponentError> {
) -> Result<Option<T>, ComponentError> {
use std::collections::hash_map::Entry;

let loc = self.entities.get_mut(entity)?;
Expand Down Expand Up @@ -741,7 +742,7 @@ impl World {
{
self.entities.get_mut(moved).unwrap().index = old_index;
}
bundle.ok_or_else(|| ComponentError::MissingComponent(MissingComponent::new::<()>()))
Ok(bundle)
}
}

Expand Down

0 comments on commit bcdf30d

Please sign in to comment.