pub struct EntityRange<I: EntityId> { /* private fields */ }Expand description
A range of IDs.
Implementations§
Source§impl<I: EntityId> EntityRange<I>
impl<I: EntityId> EntityRange<I>
Sourcepub fn new(start: usize, end: usize) -> Self
pub fn new(start: usize, end: usize) -> Self
Construct the range of IDs corresponding to start..end.
pub fn len(self) -> usize
pub fn is_empty(self) -> bool
pub fn map<T>( self, f: impl FnMut(I) -> T, ) -> impl DoubleEndedIterator<Item = T> + ExactSizeIterator<Item = T>
pub fn rev( self, ) -> impl DoubleEndedIterator<Item = I> + ExactSizeIterator<Item = I>
pub fn filter( self, f: impl FnMut(&I) -> bool, ) -> impl DoubleEndedIterator<Item = I>
Sourcepub fn end(self) -> I
pub fn end(self) -> I
Returns the upper bound of this range, even if it is empty.
In other words, returns the ID that immediately follows this range.
Sourcepub fn first(self) -> Option<I>
pub fn first(self) -> Option<I>
Returns the first ID in the range, or None if the range is empty.
Sourcepub fn last(self) -> Option<I>
pub fn last(self) -> Option<I>
Returns the last ID in the range, or None if the range is empty.
Sourcepub fn index(self, idx: usize) -> I
pub fn index(self, idx: usize) -> I
Return self[idx], conceptually.
Note that we cannot actually implement the Index trait, because
it requires us to return a reference which we cannot materialize.
Sourcepub fn index_of(&self, id: I) -> Option<usize>
pub fn index_of(&self, id: I) -> Option<usize>
Return the position of id in this range, if present.
pub fn contains(&self, id: I) -> bool
Trait Implementations§
impl<I: Copy + EntityId> Copy for EntityRange<I>
impl<I: Eq + EntityId> Eq for EntityRange<I>
Source§impl<I: EntityId> From<EntityRange<I>> for EntityBundleIndices<I>
impl<I: EntityId> From<EntityRange<I>> for EntityBundleIndices<I>
Source§fn from(value: EntityRange<I>) -> Self
fn from(value: EntityRange<I>) -> Self
Converts to this type from the input type.
Source§impl<I: EntityId> IntoIterator for EntityRange<I>
impl<I: EntityId> IntoIterator for EntityRange<I>
impl<I: PartialEq + EntityId> StructuralPartialEq for EntityRange<I>
Auto Trait Implementations§
impl<I> Freeze for EntityRange<I>where
I: Freeze,
impl<I> RefUnwindSafe for EntityRange<I>where
I: RefUnwindSafe,
impl<I> Send for EntityRange<I>
impl<I> Sync for EntityRange<I>
impl<I> Unpin for EntityRange<I>where
I: Unpin,
impl<I> UnsafeUnpin for EntityRange<I>where
I: UnsafeUnpin,
impl<I> UnwindSafe for EntityRange<I>where
I: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.