Renmusxd/RustQIP

Rewrite for 1.0

Opened this issue · 4 comments

Much of this library isn't idiomatic rust - nor is it really well written to be honest with myself.
The numerics under the hood are fine and fairly well optimized, the issue is that the UnitaryBuilder trait and pipeline constructor heavily uses dynamic dispatch. Switching over to generics and traits would allow for much more flexibility from a type system perspective.
This would require a large reorganization, and much of the responsibility of the classes would need to be moved around.

91e98a9 is the first stable large reorganization matching all the above criteria. A few modules have been dropped for now (unfortunately including the some macro support). Slowly working on reintroducing these. the program and wrap_fn/invert_fn macros really need to be rewritten as procedural macros now to properly deal with generics and the stronger type constraints introduced by no longer using the dyn keyword.

After some thought it seems the program! and wrap! / invert_fn! macros need to be significantly rethought. I believe with the strong types in the rewrite (such as no use of dyn) they can't be rewritten as macro_rules! without some significant complexity.

I am slowly learning how to write procedural macros to add these back in, since they are a cornerstone of QOL for this project.

1ab3a11 is the bulk of the program! rewrite, it is now a procedural macro living in a package adjacent to the core qip code. It can be enabled via the "macros" feature. Some of the previously supported modules are gated by this now since they make heavy use of program!

The syntax changed a bit (mostly just additional semicolons and now longer requiring vertical bars where we would have preferred parens or square brackets), I'll update docs soon.

Docs updated in f9940ca - while making the invert macro found a bug in some code from 91e98a9 for making subcircuits. This (further) tells me that I need to work on reintroducing the unit tests before working on any new 1.0 features.