Currently, this is the definition of the Unflatten trait:
pub unsafe trait Unflatten<T, NM, N>: GenericSequence<T, Length = NM>
where
NM: ArrayLength + Div<N>,
N: ArrayLength,
Quot<NM, N>: ArrayLength,
{
type Output: GenericSequence<GenericArray<T, N>, Length = Quot<NM, N>>;
fn unflatten(self) -> Self::Output;
}
However, sometimes I need to split a GenericSequence into M parts of length N instead of splitting a GenericSequence of length NM into parts of length N. The existing trait computes the chunk count via division, but I already know both dimensions in advance. While both ideas seem similar, the problem I have noticed with the current trait is that it doesn't allow for N = UTerm, whereas the other trait would. This is required for my use case of parsing an array of ZSTs, where I know the number and the size (0) of the ZSTs, but the Unflatten trait won't allow running unflatten on that.
For this reason, I propose adding a new trait with the following signature (rather than modifying the current one, as this would break compatibility):
pub unsafe trait UnflattenChunks<T, N, M>: GenericSequence<T, Length = Prod<N, M>>
where
M: ArrayLength,
N: ArrayLength + Mul<M>,
Prod<N, M>: ArrayLength,
{
type Output: GenericSequence<GenericArray<T, N>, Length = M>;
fn unflatten(self) -> Self::Output;
}
(The name of the new trait could be changed, I'm not good at naming things).
P.S. Thank you for the crate, I think it's very cool, and I've been enjoying programming with it!
Currently, this is the definition of the
Unflattentrait:However, sometimes I need to split a
GenericSequenceintoMparts of lengthNinstead of splitting aGenericSequenceof lengthNMinto parts of lengthN. The existing trait computes the chunk count via division, but I already know both dimensions in advance. While both ideas seem similar, the problem I have noticed with the current trait is that it doesn't allow forN = UTerm, whereas the other trait would. This is required for my use case of parsing an array of ZSTs, where I know the number and the size (0) of the ZSTs, but theUnflattentrait won't allow runningunflattenon that.For this reason, I propose adding a new trait with the following signature (rather than modifying the current one, as this would break compatibility):
(The name of the new trait could be changed, I'm not good at naming things).
P.S. Thank you for the crate, I think it's very cool, and I've been enjoying programming with it!