Skip to content
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

Change Into<Hertz> to TryInto<Hertz> in rcc.rs #137

Merged
merged 2 commits into from Jul 19, 2021

Conversation

rfuest
Copy link
Contributor

@rfuest rfuest commented Jul 17, 2021

In contrast to my suggestion in #136 I decided to change Into<Hertz> to TryInto<Hertz> in rcc.rs. All methods that take a frequency argument already contained assertions that would cause a panic if the value is out of range. The same assertions can also catch if TryInto<Hertz> fails.

I've also added some docs to make the user aware that these methods might panic and under which conditions.

Copy link
Contributor

@hannobraun hannobraun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @rfuest. I agree with your reasoning regarding TryInto.

I see you're a following the school of "first lines of documentation need to end with a period, even though that doesn't make sense because they're titles and not sentences". I won't hold that against you 😁

@hannobraun hannobraun merged commit c983ec0 into stm32-rs:master Jul 19, 2021
@rfuest
Copy link
Contributor Author

rfuest commented Jul 19, 2021

I see you're a following the school of "first lines of documentation need to end with a period, even though that doesn't make sense because they're titles and not sentences". I won't hold that against you grin

😁 I try to follow the precedence set by the std library docs, the API guidelines and RFC 1574. It might not make sense, but at least it's consistent 😉

@hannobraun
Copy link
Contributor

Ah, I didn't know this was the officially recommended style. Oh well, looks like I'm on the wrong side of history, yet again 😁

@hellow554
Copy link

I really would like to see a point release, because without this all builds fail that try to use a function that has a {Try,}Into<Hertz> constraint:

error[E0277]: the trait bound `Hertz: From<Megahertz>` is not satisfied
  --> src/main.rs:14:10
   |
14 |         .sysclk(216_u32.MHz())
   |          ^^^^^^ the trait `From<Megahertz>` is not implemented for `Hertz`
   |
   = help: the following implementations were found:
             <Hertz<u64> as From<Centihertz>>
             <Hertz<u64> as From<Decihertz>>
             <Hertz<u64> as From<Hertz>>
             <Hertz<u64> as From<Kibihertz>>
           and 5 others
   = note: required because of the requirements on the impl of `Into<Hertz>` for `Megahertz`

@hannobraun
Copy link
Contributor

Thanks for the note, @hellow554. I'm busy right now, but I've added releasing a new version to my task list. I hope I'll be able to get to it within the next 1-2 weeks.

@hannobraun
Copy link
Contributor

@hellow554: Version 0.5 has been published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants