diff --git a/src/internals/insert.rs b/src/internals/insert.rs index 53e41075..be2f3325 100644 --- a/src/internals/insert.rs +++ b/src/internals/insert.rs @@ -220,7 +220,13 @@ pub trait ComponentSource: ArchetypeSource { /// A collection with a known length. pub trait KnownLength { + /// Gets the length of the collection. fn len(&self) -> usize; + + /// Returns true only if the collection is empty. + fn is_empty(&self) -> bool { + self.len() == 0 + } } /// Converts a type into a [`ComponentSource`]. diff --git a/src/internals/permissions.rs b/src/internals/permissions.rs index cbd65fa5..ba4da312 100644 --- a/src/internals/permissions.rs +++ b/src/internals/permissions.rs @@ -265,11 +265,10 @@ impl Default for Permissions { impl Debug for Permissions { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn list(items: &[V]) -> String { - use itertools::Itertools; items .iter() .map(|x| format!("{:?}", x)) - .fold1(|x, y| format!("{}, {}", x, y)) + .reduce(|x, y| format!("{}, {}", x, y)) .unwrap_or_else(|| "".to_owned()) } @@ -285,11 +284,10 @@ impl Debug for Permissions { impl Display for Permissions { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn list(items: &[V]) -> String { - use itertools::Itertools; items .iter() .map(|x| format!("{}", x)) - .fold1(|x, y| format!("{}, {}", x, y)) + .reduce(|x, y| format!("{}, {}", x, y)) .unwrap_or_else(|| "".to_owned()) } diff --git a/src/storage.rs b/src/storage.rs index 3a5dcfb8..474efb1f 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -81,7 +81,7 @@ pub use crate::internals::{ hash::{ComponentTypeIdHasher, U64Hasher}, insert::{ ArchetypeSource, ArchetypeWriter, ComponentSource, ComponentWriter, IntoComponentSource, - IntoSoa, UnknownComponentWriter, + IntoSoa, KnownLength, UnknownComponentWriter, }, storage::{ archetype::{Archetype, ArchetypeIndex, EntityLayout},