korken89 / fugit

`fugit` provides a comprehensive library of `Duration` and `Instant` for the handling of time in embedded systems, doing all it can at compile time.
Apache License 2.0
55 stars 16 forks source link

Support for std::ops::Rem #41

Open DusterTheFirst opened 1 year ago

DusterTheFirst commented 1 year ago

sometimes it is useful to know if a frequency is a multiple of another frequency or of a specific integer, using the std::ops::Rem operator is the default way to check that. This trait does not seem to be implemented for any Rate types. Is there any reason for the omission, or is there another way to achieve this without the Rem operator?

korken89 commented 1 year ago

Hi @DusterTheFirst !

The only reason is that it has not been added. A PR would be appreciated! If you just want to get it working you can do it manually:

let rem = r1.raw() % r2.raw();

This does however require that the rates are in the same base and that you then crate a new rate with the same base from the remainder.

Ping me if you want to give a PR a try and would like some guidance!

Tnze commented 6 days ago

Need this too