Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/internals/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
Expand Down
6 changes: 2 additions & 4 deletions src/internals/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,10 @@ impl<T: PartialEq> Default for Permissions<T> {
impl<T: PartialEq + Debug> Debug for Permissions<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn list<V: Debug>(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())
}

Expand All @@ -285,11 +284,10 @@ impl<T: PartialEq + Debug> Debug for Permissions<T> {
impl<T: PartialEq + Display> Display for Permissions<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn list<V: Display>(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())
}

Expand Down
2 changes: 1 addition & 1 deletion src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down