Skip to content

Commit

Permalink
Steal self reference for .entangle(...)
Browse files Browse the repository at this point in the history
It's just the best way in the end.
  • Loading branch information
chemix-lunacy committed Oct 14, 2024
1 parent e72a7d0 commit 09bf43a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/rasqal/src/analysis/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,13 @@ impl AnalysisQubit {

pub fn is_entangled(&self) -> bool { !self.tangles.is_empty() }

// TODO: Remove self_pointer and decide how to deal with this. Don't want to steal the
// borrow really.
pub fn entangle(&self, self_pointer: &Ptr<AnalysisQubit>, other: &Ptr<AnalysisQubit>) {
pub fn entangle(&self, other: &Ptr<AnalysisQubit>) {
if self.is_entangled_with(&other.index) {
return;
}

let tangle = Ptr::from(Tangle::from_qubits(self_pointer, other));
with_mutable!(self_pointer.tangles.insert(other.index, tangle.clone()));
let tangle = Ptr::from(Tangle::from_qubits(&Ptr::from(self), other));
with_mutable_self!(self.tangles.insert(other.index, tangle.clone()));
with_mutable!(other.tangles.insert(self.index, tangle));
}

Expand Down

0 comments on commit 09bf43a

Please sign in to comment.