oqc-community / rasqal

A dynamically executed quantum-classical hybrid runtime.
Other
10 stars 3 forks source link

Reduce Rust unsafe code to help readability #70

Open chemix-lunacy opened 1 month ago

chemix-lunacy commented 1 month ago

See if the unsafe code can be reduced or removed to help with onboarding other people to the project.

For background: Rusts borrows are nowhere near comprehensive enough to deal with the majority of data structures in Rasqal. Due to this the singular mutability rules are increadibly restrictive. Due to this custom smart pointers were built which utilize Rusts various ways to deal with unrestricted mutability (https://github.com/rust-lang/rust/blob/334e509912d82323ff0fca016a2e69dbbee559fd/library/core/src/cell.rs#L1) and raw pointers, including some custom ways we deal with pointer expansion and contraction.

All of these will still be required, but some work should be done around making them a bit less primeval, which includes:

  1. Cleaning up the shared mutability API of the smart-pointer and making it cleaner to use and preferably entirely opaque.
  2. Remove the macro and just bake the capabilities into the smart-pointer itself.
  3. Changing many methods to mutable if they should be mutable when the smart-pointer can opaquely change betwen mutable and immutable at will.