Skip to content

Commit

Permalink
remove unneeded tests, document derive
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobsonchase committed Sep 26, 2024
1 parent 20e548a commit 33c4a98
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
18 changes: 18 additions & 0 deletions crates/bevy_ecs/src/entity/visit_entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ where
///
/// It may be useful to implement directly for types that can't produce an
/// iterator for lifetime reasons, such as those involving internal mutexes.
///
/// This trait is derivable for structs via `#[derive(IterEntities)]`. Fields
/// not containing entities can be ignored with `#[iter_entities(ignore)]`.
///
/// # Example
///
/// ```rust
/// # use bevy_ecs::entity::{Entity, IterEntities};
/// # use bevy_utils::hashbrown::HashSet;
/// #[derive(IterEntities)]
/// struct MyEntities {
/// lots: Vec<Entity>,
/// one: Entity,
/// maybe: Option<Entity>,
/// #[iter_entities(ignore)]
/// not_an_entity: String,
/// }
/// ```
pub trait IterEntities {
/// Get an iterator over contained entities.
fn iter_entities(&self) -> impl Iterator<Item = Entity>;
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,8 @@ mod tests {
#[derive(Component, IterEntities)]
struct MyEntities {
entities: Vec<Entity>,
entities2: Vec<Entity>,
another_one: Entity,
maybe_entity: Option<Entity>,
#[iter_entities(ignore)]
something_else: String,
}
Expand Down
14 changes: 0 additions & 14 deletions crates/bevy_hierarchy/src/components/children.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,3 @@ impl<'a> IntoIterator for &'a Children {
self.0.iter()
}
}

#[cfg(test)]
mod test {
use bevy_ecs::entity::VisitEntities;

use super::*;

fn assert_impls_map_entities<M: VisitEntities>() {}

#[test]
fn children_impls_map_entities() {
assert_impls_map_entities::<Children>();
}
}
11 changes: 0 additions & 11 deletions crates/bevy_window/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,19 +1219,8 @@ pub struct ClosingWindow;

#[cfg(test)]
mod tests {
use bevy_ecs::entity::VisitEntities;

use super::*;

// Compile-time assertion that a type implements MapEntitiesMut
fn impl_map_entities<M: VisitEntities>() {}

// Ensure that WidowRef implements MapEntitiesMut
#[test]
fn window_impls_map_entities() {
impl_map_entities::<WindowRef>();
}

// Checks that `Window::physical_cursor_position` returns the cursor position if it is within
// the bounds of the window.
#[test]
Expand Down

0 comments on commit 33c4a98

Please sign in to comment.