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 api safe #42

Merged
merged 7 commits into from
Jan 19, 2024
Merged

Feat api safe #42

merged 7 commits into from
Jan 19, 2024

Conversation

a-barlow
Copy link
Owner

@a-barlow a-barlow commented Jan 19, 2024

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 circuit has two public fields that could be altered, resulting in the simulation not working as key assumptions are broken.

There was a mistake in the previous update (0.4.1) where the method Circuit::get_num_qubits consumed the circuit, when in fact it should borrow.

The quantr errors are public, which may lead to breaking changes in the future. They offer no extra functionality either, other than implementing the std::error::Error trait.

How does this fix and/or better quantr?

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

The fields of Circuit have been made private, in addition to all other structs in quantr. Now, the simulation's assumptions can be held up.

The Circuit::get_num_qubits method has now been made to borrow the circuit.

The quantr errors have been made private, forcing the user to handle them through the trait std::error::Error. This allows for future builds of quantr to differ in their error type.

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.

Major.

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 public interface with quantr has now been made completely safe (so
the user cannot destrouy asssumptions essential for the simualtion of
the circuit), in addition to adding an extra error struct to handle
constant errors. This will allow some functions to be made constant.

Signed-off-by: Andrew Barlow <a.barlow.dev@gmail.com>
This automatically produces a to_string method for this ProductState, in
addition to allowing more functionality when it is being written to the
console.

Signed-off-by: Andrew Barlow <a.barlow.dev@gmail.com>
Signed-off-by: Andrew Barlow <a.barlow.dev@gmail.com>
Signed-off-by: Andrew Barlow <a.barlow.dev@gmail.com>
Errors have been made publicly availble again, however the fields cannot
be altered. The error can be used through the error trait.

Signed-off-by: Andrew Barlow <a.barlow.dev@gmail.com>
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 5a51aca into dev Jan 19, 2024
1 check passed
@a-barlow a-barlow deleted the feat-api-safe branch January 19, 2024 13:48
@a-barlow a-barlow mentioned this pull request Jan 19, 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.

None yet

1 participant