import warnings


def measure(circuit, qubit, clbit):
    """Measure a quantum bit into classical bit.

    .. deprecated:: Qiskit Terra 0.19
        Use :meth:`.QuantumCircuit.measure` instead, either by calling
        ``circuit.measure(qubit, clbit)``, or if a full function is required, then
        ``QuantumCircuit.measure(circuit, qubit, clbit)``.

    Args:
        circuit (QuantumCircuit): the quantum circuit to attach the measurement to.
        qubit (Union[Qubit, int]): the quantum bit to measure
        clbit (Union[Clbit, int]): the classical bit to store the measurement result in.

    Returns:
        .InstructionSet: a handle to the created instruction.

    Raises:
        CircuitError: if either bit is not in the circuit, or is in a bad format.
    """
    warnings.warn(
        "The loose 'measure' function is deprecated as of Qiskit Terra 0.19, and will be removed"
        " in a future release.  Instead, you should call 'circuit.measure(qubit, clbit)', or if you"
        " need a function, you can do `QuantumCircuit.measure(circuit, qubit, clbit)'.",
        category=DeprecationWarning,
        stacklevel=2,
    )
    return circuit.measure(qubit, clbit)