aboutsummaryrefslogtreecommitdiff
path: root/stockton-types/src/world.rs
diff options
context:
space:
mode:
Diffstat (limited to 'stockton-types/src/world.rs')
-rw-r--r--stockton-types/src/world.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/stockton-types/src/world.rs b/stockton-types/src/world.rs
index 18a0edf..1196592 100644
--- a/stockton-types/src/world.rs
+++ b/stockton-types/src/world.rs
@@ -35,21 +35,20 @@ impl<'a> World<'a> {
///
/// `mapper` is called for each BSPEntity to map it to a concrete rust type.
pub fn new<F>(bsp: Pin<Box<BSPFile<'a>>>, mut mapper: F) -> Option<World<'a>>
- where F: FnMut(&BSPEntity) -> (Box<Entity>, String) {
+ where F: FnMut(&BSPEntity) -> Option<(Box<Entity>, String)> {
let mut entities: Vec<(Box<Entity>, String)> = Vec::with_capacity(bsp.entities.entities.len());
for bsp_ent in bsp.entities.entities.iter() {
- entities.push(mapper(&bsp_ent));
+ if let Some(result) = mapper(&bsp_ent) {
+ entities.push(result);
+ }
}
- let store = EntityStore::from_entities(entities);
- if store.is_none() {
- return None;
- }
+ let store = EntityStore::from_entities(entities)?;
Some(World {
map: bsp,
- live_entities: store.unwrap()
+ live_entities: store
})
}
} \ No newline at end of file