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

Refactor: use monadic operators and prefer NonZeroU64 for seconds #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

BastiDood
Copy link

Hello there! Fun little project here. Figured that a little bit of cleanup would be appreciated. In this PR:

  • I transformed the long, nested match statements into their monadic counterparts so that the control flow is more "flat" and "linear", so to speak.
  • I replaced the seconds option to take in an Option<NonZeroU64> instead of an Option<u64>. This allows the compiler to optimize for memory layout. The former ensures that seconds is represented in memory as if it were a plain u64 (which is not the case for the latter). Moreover, it doesn't make sense to provide zero delay, anyway. 😅
  • Finally, I ensured that the program panics if it can't move the mouse. I figured that this would be the intentional behavior so that there are no surprises in case errors do arise.

That is all. Thanks! 🎉

This is mainly for the sake of optimizing the memory layout.
Also, it doesn't make sense to provide zero delay, anyway.
We probably meant to panic in case things don't go well.
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.

1 participant