Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JieningYu committed Feb 2, 2024
1 parent 8b09795 commit 1900104
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
21 changes: 19 additions & 2 deletions util/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ impl<'a, K, T> Iterator for Entries<'a, K, T> {
}
}
}

fn size_hint(&self) -> (usize, Option<usize>) {
match &self.inner {
EntriesInner::Direct { iter, .. } => iter.size_hint(),
EntriesInner::Raw { iter, .. } => iter.size_hint(),
}
}
}

/// Iterator of entry references of a tag.
Expand All @@ -308,6 +315,11 @@ impl<'a, K, T> Iterator for OfTag<'a, K, T> {
fn next(&mut self) -> Option<Self::Item> {
self.inner.next().and_then(|i| self.registry.of_raw(i))
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.inner.size_hint()
}
}

/// Iterator of entry values.
Expand All @@ -323,6 +335,11 @@ impl<'a, K, T> Iterator for Values<'a, K, T> {
fn next(&mut self) -> Option<Self::Item> {
self.inner.next().and_then(RefEntry::value)
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.inner.size_hint()
}
}

impl<'a, K, T> IntoIterator for &'a Registry<K, T> {
Expand Down Expand Up @@ -658,11 +675,11 @@ impl crate::key::Root for rimecraft_identifier::vanilla::Identifier {
}
}

#[cfg(feature = "vanilla-registry")]
#[cfg(feature = "vanilla-identifier")]
#[doc = "`Registry` using vanilla `Identifier`."]
pub type VanillaRegistry<T> = Registry<rimecraft_identifier::vanilla::Identifier, T>;

#[cfg(feature = "vanilla-registry")]
#[cfg(feature = "vanilla-identifier")]
#[doc = "Mutable `Registry` using vanilla `Identifier`."]
pub type VanillaRegistryMut<T> = RegistryMut<rimecraft_identifier::vanilla::Identifier, T>;

Expand Down
5 changes: 5 additions & 0 deletions util/registry/src/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ impl<'a, K, T> Iterator for Iter<'a, K, T> {
)
})
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.inner.size_hint()
}
}

#[cfg(feature = "serde")]
Expand Down

0 comments on commit 1900104

Please sign in to comment.