-
Notifications
You must be signed in to change notification settings - Fork 71
MVP: Make use of const generics #224
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
Conversation
preperation for const generics
Hey @Piroro-hs, I would like to ask you for your help. The initial motivation of the PR making use of const generics was the gnarly error message introduced by #189, like I stumbled upon these error messages, while implementing test cases in #212, I know that I don't know what to do though. Reverting #189 would be the easiest way, but your great improvement are worthwhile, and I would like to keep them. The easiest way I was thinking about, is adding a new generic type PXx (which is distinct from the current generic Pin) type, which has no generic parameter about the pin number. This would result into many duplications though, as we have to implement many methods again for this pin (which would reintroduce some macro bulk which you have been getting rid of in your improvment PR) Do you have any idea or suggestion @Piroro-hs ? |
prototyping: https://github.com/Piroro-hs/stm32f3xx-hal/tree/untypenum Main idea is that using this simple struct instead of pub struct U<const X: u8>; Error message looks like this.
|
Well this is a much simpler solution than mine 😀 And it solves the problem the most prominent problem of typeenum error types. Let's go your route for now. Switching to ~~What I still might suggest in incorporate 1ef350a with your (Piroro-hs@b34576b) change, so that we can switch to EDIT: So you were taking the other approach, not replacing all instances where This is a viable approch, I'm waiting for a PR 😋 |
This is a MVP of using const generics, based on the refactoring of the GPIO module in #189
The current implementation leaves out the
downgrade()
method to get a generic pin type, which is a major loss.This is because we can not be generic over
Unsigned
via min const generics.min const generic does not allow any const generics in
where
clauses, and I'm not really sure, if this would be the right approach even if we had full const generics available.Maybe there are some improvements to be made, which would allow not having to remove this method.