You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It might be useful to have a utility type which allows producing collections up to a certain length. Perhaps:
/// * N = max size/// * C = collection type/// * T = element typestructUpTo<constN:usize,C,T>{ ... }impl<constN:usize,C,T>UpTo<N,C,T>{fninto_inner(self) -> C{ ...}}impl<constN:usize,C,T>ExhaustforUpTo<N,C,T>whereT:Exhaust,C:FromIterator<T>,{ ... }
This is not a very elegant interface, but the important part of deciding whether to provide it is how difficult the algorithm to actually produce the items turns out to be — how much work we save the user. (Perhaps we should expose the algorithm and not a type that uses it?) For small cases, a user could just
but that can't be generic over length, and is sorted by length instead of lexicographically. Another derive-based approach, producing lexicographic ordering, would be
It might be useful to have a utility type which allows producing collections up to a certain length. Perhaps:
This is not a very elegant interface, but the important part of deciding whether to provide it is how difficult the algorithm to actually produce the items turns out to be — how much work we save the user. (Perhaps we should expose the algorithm and not a type that uses it?) For small cases, a user could just
but that can't be generic over length, and is sorted by length instead of lexicographically. Another derive-based approach, producing lexicographic ordering, would be
but again, it isn't const generic and would give the compiler a lot of work to do.
The text was updated successfully, but these errors were encountered: