forked from Qiskit/qiskit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce type-safety in
NeighborTable
This hides the internal `.neighbors` field in favour of instead implemented `Index<PhysicalQubit>` on the entire `NeighborTable` struct. This is done because indexing into `.neighbors` required calling `PhysicalQubit::index` to retrieve a `usize`, but a similar method also exists on `VirtualQubit`. This meant that it was previously a normal API pattern to do `neighbors.neighbors[qubit.index()]`, and this threw away the type safety: it would compile without warning whether `qubit` was physical or virtual. To support the hiding of the `.neighbors` field, the constructor of the coupling map is moved to be an associated function on `NeighborTable`, so the unsafe access only happens within the context of all other unsafe operations.
- Loading branch information
1 parent
8018716
commit 452ad44
Showing
2 changed files
with
27 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters