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

[Merged by Bors] - Replace the bool argument of Timer with TimerMode #6247

Closed
wants to merge 6 commits into from
Closed

[Merged by Bors] - Replace the bool argument of Timer with TimerMode #6247

wants to merge 6 commits into from

Commits on Oct 13, 2022

  1. add TimerMode, replace repeating: bool

    As mentioned in #2926, it's better to have an explicit type that clearly
    communicates the intent of the timer mode rather than an opaque boolean,
    which can be only understood when knowing the signature or reading the
    documentation.
    
    Signed-off-by: Lena Milizé <me@lvmn.org>
    lovelymono committed Oct 13, 2022
    Configuration menu
    Copy the full SHA
    5a58300 View commit details
    Browse the repository at this point in the history
  2. replace set_repeating with set_mode

    Replaces Timer::set_repeating and Timer::repeating with Timer::set_mode
    and Timer::mode, respectively.
    
    Adds PartialEq, Eq, Hash to TimerMode. Replaces impl Default with derive
    macro.
    
    Signed-off-by: Lena Milizé <me@lvmn.org>
    lovelymono committed Oct 13, 2022
    Configuration menu
    Copy the full SHA
    4881f87 View commit details
    Browse the repository at this point in the history
  3. fix doc tests and tests after 4881f87

    Signed-off-by: Lena Milizé <me@lvmn.org>
    lovelymono committed Oct 13, 2022
    Configuration menu
    Copy the full SHA
    3e6cbd1 View commit details
    Browse the repository at this point in the history
  4. replace assert!(timer.mode() == Repeating) with assert_eq!

    Signed-off-by: Lena Milizé <me@lvmn.org>
    lovelymono committed Oct 13, 2022
    Configuration menu
    Copy the full SHA
    d5f752e View commit details
    Browse the repository at this point in the history
  5. remove TimerMode::repeating

    tguichaoua:
    > The problem with utility methods is that if you want to be consistant
    > you have to add one for each variant for each enum. That is complex to
    > maintain.
    > For fieldless enums using equality is more straightforward and seems
    > to be the most used way in the rust community.
    
    Signed-off-by: Lena Milizé <me@lvmn.org>
    lovelymono committed Oct 13, 2022
    Configuration menu
    Copy the full SHA
    ea23581 View commit details
    Browse the repository at this point in the history
  6. replace assert_ne with assert_eq

    We want to check that the timer is what we set it to, and before the
    condition was backwards.
    
    Signed-off-by: Lena Milizé <me@lvmn.org>
    lovelymono committed Oct 13, 2022
    Configuration menu
    Copy the full SHA
    88ddcc5 View commit details
    Browse the repository at this point in the history