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

Feat improve maintenance #39

Merged
merged 2 commits into from
Jan 11, 2024
Merged

Feat improve maintenance #39

merged 2 commits into from
Jan 11, 2024

Conversation

a-barlow
Copy link
Owner

I acknowledge that:

  • my code passes all tests by running cargo test;
  • my code is formatted with cargo fmt;
  • my code successfully compiles the documentation without warnings
    using cargo doc;
  • I have updated CHANGELOG.md documenting what was changed/added;
  • I have added unit testing to test my new code (if applicable);
  • I have signed off on all commits with my name and email;
  • I have answered all the questions below and given justification
    where appropriate; and
  • I am merging with the dev branch.

What is the current problem, or feature that should be added?

What aspect of the project needs changing?

The code itself was hard to maintain as there were a lot of match statements, that were not really exhaustive, and lead to a spaghetti of functions. There were also a scattering of mistakes that cargo clippy suggested to fix.

How does this fix and/or better quantr?

If it's a feature, please add examples on how you would use it.

Now, the code makes proper use of the exhaustive nature of match statements, leading to a huge reduction in code for the main simulation. Moreover, loads of panic statements have been removed. This has increased the readability and maintainability of the main simulation algorithm. For instance, if there were to be a new gate added, the compiler would be able to better guide the developer through what new branches in match statements would have to be added.

Is this pull request a major or minor change with respect to the dev branch?

Please refer to semantic versioning for Rust. If this is a major/breaking change, please add an explanation to why it could not be minor, or equally why it should break the current version.

Minor

What do the unit tests cover?

Description of the unit tests added (if applicable).

Not applicable.

Additional comments.

Any more justifications, examples of output, or even suggestions for improving this pull request template are all welcome!

The `GateSize` enum has been replaced with `GateCategories` that makes
better use of match statements, by allowing a completely exhaustive
pattern. This has reduced code massively, in addition to reducing the
number of panic statements and unnecessary branches in the match
statements.

The GateSize was used in the printer struct, however that's been removed
too. More code cleaning needs to be done for this file, for
maintainability reasons, but this will be left for a future update.

Lastly, most functions that linked the gates to functions, names or
returning control nodes have been moved to `gates.rs`.

Signed-off-by: Andrew Barlow <a.barlow.dev@gmail.com>
Signed-off-by: Andrew Barlow <a.barlow.dev@gmail.com>
@a-barlow a-barlow merged commit 9d2be2c into dev Jan 11, 2024
1 check passed
@a-barlow a-barlow deleted the feat-improve-maintenance branch January 11, 2024 16:12
@a-barlow a-barlow mentioned this pull request Jan 11, 2024
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