Skip to content
Discussion options

You must be logged in to vote

@mark-koch points out this is in fact possible with the with_owned guppy feature:

from guppylang import guppy
from guppylang.std.quantum import qubit, discard
from guppylang.std.builtins import owned
from guppylang.std.mem import with_owned

@guppy
def borrowed_reset(q: qubit) -> None:
    def discard_and_realloc(q: qubit @owned) -> tuple[None, qubit]:
        discard(q)
        return None, qubit()

    with_owned(q, discard_and_realloc)

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@perlinm
Comment options

@ss2165
Comment options

@perlinm
Comment options

@ss2165
Comment options

Answer selected by ss2165
@perlinm
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants