-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial migration from const-generics to typenum #189
base: main
Are you sure you want to change the base?
Conversation
(Not the developer, just curious) Could you expand on what the motivation for moving away from const generics is here? |
typenum allows you to do things like specify legal values at compile time, as well as removes the need to choose an integer type until runtime. For example, if you wanted to implement a "sub-matrix" extension trait, you could constrain it so its width and height is less than the matrix it's extending. when you are placing it in the "super-matrix", you can constrain it so that it's left most column, plus its width is less than the width of the super-matrix, and similarly for the highest row. this is all at compile time. as for integer types, you do not need to choose usize, u32, etc., until an actual machine-representation of the integer is required. |
Thank you for the explanation! |
Another way to put it: const generics allow you to specify "use u32/usize/u64/etc here", typenum says "use any integer value here", and you can specify what "legal" is (non-zero, even/odd, the result of arithmetic, etc) oh yeah, that's the other thing: you can do arithmetic with typenum. no need for |
I've looked through the PR, afaict,
|
After our discussion in DMs, I'd be happy to re-write the PR so that it only affects the internal code-base, and not the public facing API. |
This is an initial PoC of what a migration to use of
typenum
andGenericArray
might look like.