I wanted a casting iterator for ReadIndices that would try to cast indices into u16s rather than u32s. I've implemented this feature, but not totally sure if it's something you would want to merge: here it is https://gist.github.com/ickk/da6a34cb6d3b4199d865d854fc8be0c4
With the linked gist, it becomes possible to call ReadIndices::try_into_u16, which returns an Option<CastingIter<'_, u16>>. It checks the variant of ReadIndices only once, making this efficient.
Caveats: It is obviously possible to have u32 indices that are all <= u16::MAX but in this case try_into_u16 cannot know this ahead of time and returns None. This makes try_into_u16 less useful in practice - you would have to have a separate branch to additionally handle TryFrom<u32> if assets may contain u32 indices.
If you'd like for me to PR this anyway (perhaps with a better name?) I will be glad to do so
I wanted a casting iterator for
ReadIndices
that would try to cast indices intou16
s rather thanu32
s. I've implemented this feature, but not totally sure if it's something you would want to merge: here it is https://gist.github.com/ickk/da6a34cb6d3b4199d865d854fc8be0c4With the linked gist, it becomes possible to call
ReadIndices::try_into_u16
, which returns anOption<CastingIter<'_, u16>>
. It checks the variant ofReadIndices
only once, making this efficient.Caveats: It is obviously possible to have
u32
indices that are all<= u16::MAX
but in this casetry_into_u16
cannot know this ahead of time and returnsNone
. This makestry_into_u16
less useful in practice - you would have to have a separate branch to additionally handleTryFrom<u32>
if assets may containu32
indices.If you'd like for me to PR this anyway (perhaps with a better name?) I will be glad to do so