secsy_ecs 0.0.2

Deprecated, don't use this
Documentation
/// Spawn an entity with some components already set.
/// Returns a `Result` containing the entity or a `ComponentAddError`.
///
/// Example:
/// ```
/// use secsy_ecs::world::*;
/// use secsy_ecs::entities::*;
///
/// let mut w = World::new();
///
/// let e = secsy_ecs::spawn_entity_with!(w, 621, 621.0)
///     .expect("One of added components already exists");
/// let _f = secsy_ecs::spawn_entity_with!(w, 621, 621.0)
///     .expect("One of added components already exists");
///
/// assert_eq!(w.get::<i32>(e).unwrap(), 621);
/// assert_eq!(w.get::<f64>(e).unwrap(), 621.0);
///```
#[macro_export]
macro_rules! spawn_entity_with {
    ($world:ident, $($components:expr),+) => {{
        let w: &mut World = &mut $world;
        let e = w.spawn();

        let mut result: Result<EntityId, ComponentAddError> =
            Err(ComponentAddError::ComponentExistsOnEntity);

        $({
            let add_result = w.add_to(e, $components);

            if let Ok(_) = add_result {
                result = Ok(e);
            }
        })+

        result
    }};
}