Skip to main content

StabilizerState

Struct StabilizerState 

Source
pub struct StabilizerState {
    pub num_qubits: usize,
    /* private fields */
}
Expand description

Stabilizer state simulator based on the Aaronson-Gottesman symplectic tableau.

Represents an n-qubit stabilizer state using 2n generator rows, each composed of an X-block and Z-block of packed u64 words, plus a phase per row.

Fields§

§num_qubits: usize

Number of qubits.

Implementations§

Source§

impl StabilizerState

Source

pub fn new(n: usize) -> Self

Creates a new stabilizer state initialized to |0…0⟩.

In the Aaronson-Gottesman convention the initial generators are:

  • Destabilizer i (row i): X on qubit i, identity elsewhere, phase +1.
  • Stabilizer i (row n+i): Z on qubit i, identity elsewhere, phase +1.
§Arguments
  • n — number of qubits
Source

pub fn apply_cx( &mut self, control: usize, target: usize, ) -> Result<(), QisError>

Applies the CNOT (CX) gate with control as control and target as target.

Aaronson-Gottesman rule (Eq. 11) for each row i:

  • phase[i] ^= 2 * x[i][c] * z[i][t] * (x[i][t] ^ z[i][c] ^ 1)
  • x[i][t] ^= x[i][c]
  • z[i][c] ^= z[i][t]
Source

pub fn apply_swap(&mut self, q0: usize, q1: usize) -> Result<(), QisError>

Applies the SWAP gate between qubits q0 and q1.

Native rule: for each row i, swap (x[i][q0], z[i][q0]) with (x[i][q1], z[i][q1]). No phase change — SWAP maps Paulis without sign.

Source

pub fn apply_cz(&mut self, q0: usize, q1: usize) -> Result<(), QisError>

Applies the CZ gate (controlled-Z) between q0 and q1.

Implemented as (I⊗H)·CNOT·(I⊗H) inlined per-row — no heap allocations.

Source

pub fn apply_cy( &mut self, control: usize, target: usize, ) -> Result<(), QisError>

Applies the CY gate (controlled-Y) between control and target.

Implemented as (I⊗S)·CX·(I⊗S†) inlined per-row, i.e. in time order: S†(target) → CX(control, target) → S(target).

Derivation: Y = SXS†, so CY = (I⊗S)·CX·(I⊗S†).

Source

pub fn num_qubits(&self) -> usize

Returns the number of qubits.

Source

pub fn apply_h(&mut self, qubit: usize) -> Result<(), QisError>

Applies the Hadamard gate to qubit qubit.

Aaronson-Gottesman update rule for each row i (0..2n):

  • phase[i] ^= 2 * x[i][qubit] & z[i][qubit] (adds 2 mod 4 when Y, i.e. sign flip)
  • swap x[i][qubit] and z[i][qubit]
Source

pub fn apply_s(&mut self, qubit: usize) -> Result<(), QisError>

Applies the S gate (phase gate, √Z) to qubit qubit.

Aaronson-Gottesman rule for each row i:

  • phase[i] ^= 2 * x[i][qubit] * z[i][qubit]
  • z[i][qubit] ^= x[i][qubit]

Effect: X→Y, Y→-X, Z→Z.

Source

pub fn apply_sdg(&mut self, qubit: usize) -> Result<(), QisError>

Applies the S† gate (S-dagger, inverse phase gate) to qubit qubit.

Native rule for each row i (derived from S†: X→-Y, Y→X, Z→Z):

  • phase[i] ^= 2 * x[i][qubit] * (1 - z[i][qubit]) (flip sign when X but not yet Y)
  • z[i][qubit] ^= x[i][qubit]
Source

pub fn apply_x(&mut self, qubit: usize) -> Result<(), QisError>

Applies the Pauli-X (bit-flip) gate to qubit qubit.

Effect: X→X, Y→-Y, Z→-Z. Rule per row i: phase[i] ^= 2 * z[i][qubit]. No bit changes.

Source

pub fn apply_z(&mut self, qubit: usize) -> Result<(), QisError>

Applies the Pauli-Z (phase-flip) gate to qubit qubit.

Effect: X→-X, Y→-Y, Z→Z. Rule per row i: phase[i] ^= 2 * x[i][qubit]. No bit changes.

Source

pub fn apply_y(&mut self, qubit: usize) -> Result<(), QisError>

Applies the Pauli-Y gate to qubit qubit.

Effect: X→-X, Y→Y, Z→-Z. Rule per row i: phase[i] ^= 2 * (x[i][qubit] XOR z[i][qubit]). No bit changes.

Source

pub fn apply_x2p(&mut self, qubit: usize) -> Result<(), QisError>

Applies the √X gate (X2P, SX, Rx(π/2)) to qubit qubit.

Conjugation: X→X, Y→Z, Z→−Y. Rule per row i:

  • phase[i] ^= 2 * (!x[i][qubit] & z[i][qubit]) (flip for Z→−Y)
  • x[i][qubit] ^= z[i][qubit]
Source

pub fn apply_x2m(&mut self, qubit: usize) -> Result<(), QisError>

Applies the √X† gate (X2M, SXdg, Rx(−π/2)) to qubit qubit.

Conjugation: X→X, Y→−Z, Z→Y. Rule per row i:

  • phase[i] ^= 2 * (x[i][qubit] & z[i][qubit]) (flip for Y→−Z)
  • x[i][qubit] ^= z[i][qubit]
Source

pub fn apply_y2p(&mut self, qubit: usize) -> Result<(), QisError>

Applies the √Y gate (Y2P, SY, Ry(π/2)) to qubit qubit.

Conjugation U P U†: X→−Z, Y→Y, Z→X. Rule per row i:

  • phase[i] ^= 2 * (x[i][qubit] & !z[i][qubit]) (flip for X→−Z)
  • swap x[i][qubit] ↔ z[i][qubit]
Source

pub fn apply_y2m(&mut self, qubit: usize) -> Result<(), QisError>

Applies the √Y† gate (Y2M, SYdg, Ry(−π/2)) to qubit qubit.

Conjugation U P U†: X→Z, Y→Y, Z→−X. Rule per row i:

  • phase[i] ^= 2 * (!x[i][qubit] & z[i][qubit]) (flip for Z→−X)
  • swap x[i][qubit] ↔ z[i][qubit]
Source

pub fn measure(&mut self, qubit: usize) -> Result<bool, QisError>

Measures qubit qubit in the Z basis, collapsing the state.

Returns false for outcome 0 (+1 eigenvalue) and true for outcome 1 (-1 eigenvalue).

§Algorithm (Aaronson-Gottesman §IV)

Random case — some stabilizer generator has X or Y on qubit qubit:

  1. Find any stabilizer row p (index n..2n) with x[p][qubit] = 1.
  2. XOR row p into every other row that also has x[.][qubit] = 1.
  3. Move row p to its paired destabilizer row p - n.
  4. Replace stabilizer row p with ±Z_qubit, where the sign is random.

Deterministic case — all stabilizers commute with Z_qubit:

  1. Compute the product of destabilizer rows i (for which the paired stabilizer n+i has x[n+i][qubit] = 1) into a scratch accumulator.
  2. The measurement outcome is the phase of the scratch row.
Source

pub fn measure_all(&mut self) -> Outcome

Measures all qubits in order, returning a bit-packed Outcome.

Qubit q’s result is stored at bit q inside the Outcome. Use Outcome::is_one(q) to read it.

Source

pub fn reset(&mut self, qubit: usize) -> Result<(), QisError>

Resets qubit to the |0⟩ state.

Implemented by measuring in the Z basis and applying X if the outcome is |1⟩. This correctly handles both deterministic and random measurement cases.

§Example
use cqlib_core::qis::StabilizerState;

let mut s = StabilizerState::new(2);
s.apply_x(0).unwrap();  // |0⟩ → |1⟩
s.reset(0).unwrap();    // back to |0⟩
assert_eq!(s.probabilities().unwrap()[0], 1.0); // P(|00⟩) = 1
Source

pub fn probability_of(&self, bits: &[bool]) -> Result<f64, QisError>

Returns the probability of measuring the given computational basis state.

Performs O(n²) work per qubit, O(n³) total, on a cloned (non-destructive) copy.

§Returns
  • Ok(0.0) if the bitstring is inconsistent with the stabilizer state.
  • Ok(1.0 / 2.0^k) where k is the number of qubits with random outcomes, if the bitstring is in the support.
  • Err(QubitMismatch) if bits.len() != n.
§Example
use cqlib_core::qis::StabilizerState;

let mut s = StabilizerState::new(2);
s.apply_h(0).unwrap();
s.apply_cx(0, 1).unwrap(); // Bell state |Φ⁺⟩

// Only |00⟩ and |11⟩ are possible, each with probability 0.5
assert!((s.probability_of(&[false, false]).unwrap() - 0.5).abs() < 1e-10);
assert!((s.probability_of(&[true,  true ]).unwrap() - 0.5).abs() < 1e-10);
assert_eq!(s.probability_of(&[false, true]).unwrap(), 0.0);
assert_eq!(s.probability_of(&[true,  false]).unwrap(), 0.0);
Source

pub fn probabilities(&self) -> Result<Vec<f64>, QisError>

Returns the full probability distribution over all computational basis states.

Returns a Vec<f64> of length 2^n where entry i is the probability of measuring the state whose binary representation is i (qubit 0 = LSB).

§Limitations

Only feasible for small systems. Returns Err(InvalidParameterValue) if n > 20 (which would require a 8 MB vector and O(2^20 × n³) computation).

§Example
use cqlib_core::qis::StabilizerState;

let mut s = StabilizerState::new(2);
s.apply_h(0).unwrap();
s.apply_cx(0, 1).unwrap(); // Bell state

let probs = s.probabilities().unwrap();
assert_eq!(probs.len(), 4);
assert!((probs[0b00] - 0.5).abs() < 1e-10); // |00⟩
assert_eq!(probs[0b01], 0.0);                // |10⟩ (qubit-0 is LSB)
assert_eq!(probs[0b10], 0.0);                // |01⟩
assert!((probs[0b11] - 0.5).abs() < 1e-10); // |11⟩
Source

pub fn sample_shots(&self, shots: usize) -> Vec<Outcome>

Runs shots independent measurements in parallel using Rayon.

Returns a Vec<Outcome> of bit-packed measurement results, one per shot. Each Rayon worker thread reuses a single pre-allocated working copy of the state (via reset_from), avoiding per-shot heap allocation.

Seeds for each shot are derived sequentially from the primary RNG (ensuring reproducibility), then each shot runs on an independently-seeded clone in parallel. This produces the correct marginal distribution while being deterministic: the same initial state always yields the same joint sample set.

§Example
use cqlib_core::qis::StabilizerState;
let mut s = StabilizerState::new(2);
s.apply_h(0).unwrap();
s.apply_cx(0, 1).unwrap(); // Bell state
let results = s.sample_shots(1000);
assert_eq!(results.len(), 1000);
for shot in &results { assert_eq!(shot.is_one(0), shot.is_one(1)); }
Source

pub fn sample_shots_with_seed( &self, shots: usize, seed: Option<u64>, ) -> Vec<Outcome>

Samples using per-shot random streams independent of Rayon scheduling. With no seed, preserves the state’s existing random stream.

Source

pub fn sample( &self, measurement: &Measurement, shots: usize, ) -> Result<ExecutionResult, QisError>

Samples the state using a circuit Measurement as the output contract.

Unlike apply_circuit, this method does not read or execute the circuit IR. The Measurement already carries the qubits and their result bit order:

  • measurement.qubits()[i] becomes bit i in each Outcome.
  • Outcome::to_bitstring displays the most-significant result bit first, so string order is the reverse of measurement.qubits().
§Example
use cqlib_core::circuit::{Circuit, Qubit};
use cqlib_core::qis::StabilizerState;

let mut c = Circuit::new(2);
c.h(Qubit::new(0)).unwrap();
c.cx(Qubit::new(0), Qubit::new(1)).unwrap();
let out = c.measure_bits([Qubit::new(1), Qubit::new(0)]).unwrap();

// `from_circuit` ignores terminal measurements and keeps the Bell state.
let state = StabilizerState::from_circuit(&c).unwrap();
let result = state.sample(&out, 1000).unwrap();

assert_eq!(result.shots(), 1000);
assert!(result
    .counts()
    .keys()
    .all(|bits| bits.to_bitstring(out.width()) == "00"
        || bits.to_bitstring(out.width()) == "11"));
Source

pub fn sample_with_seed( &self, measurement: &Measurement, shots: usize, seed: Option<u64>, ) -> Result<ExecutionResult, QisError>

Projects seeded full-state samples onto the requested measurement.

Source

pub fn probs( &self, measurement: &Measurement, ) -> Result<HashMap<Outcome, f64>, QisError>

Returns the probability distribution selected by a circuit Measurement.

This is a marginal distribution over measurement.qubits(), not the full 2^n state distribution. The returned Outcome keys use the same bit order as sample.

v1 intentionally reuses probabilities, so it has the same n <= 20 limit. Use sample for larger states.

Source

pub fn from_circuit(circuit: &Circuit) -> Result<Self, QisError>

Constructs a StabilizerState by simulating a Clifford circuit.

This state-level entry point only performs quantum state evolution. Terminal measurement and store operations produced by Circuit::measure* are treated as output declarations and ignored here: they do not collapse the state and do not populate runtime classical data.

Use sample or probs with the returned Measurement to query measurement distributions from the final state. Use run_circuit when you need execution semantics where measurements collapse the state and write classical data.

§Supported instructions
  • Gates: I, H, X, Y, Z, S, SDG, X2P, X2M, Y2P, Y2M, CX, CY, CZ, SWAP
  • Classical data: MeasureBit, MeasureBits, Store are ignored
  • Directives: Reset (returns qubit to |0⟩), Barrier/Delay (no-op)
§Example
use cqlib_core::circuit::{Circuit, Qubit};
use cqlib_core::qis::StabilizerState;

let mut c = Circuit::new(2);
c.h(Qubit::new(0)).unwrap();
c.cx(Qubit::new(0), Qubit::new(1)).unwrap();
let out = c
    .measure_bits([Qubit::new(1), Qubit::new(0)])
    .unwrap();

// The measurement above is an output declaration for state sampling.
// It does not collapse the Bell state during `from_circuit`.
let stab = StabilizerState::from_circuit(&c).unwrap();
let probs = stab.probs(&out).unwrap();
assert!((probs.values().sum::<f64>() - 1.0).abs() < 1e-10);
Source

pub fn apply_circuit(&mut self, input_circuit: &Circuit) -> Result<(), QisError>

Applies a Clifford circuit to this stabilizer state in-place.

Once bound to circuit qubit IDs, subsequent circuits must have the same IDs in the same order. The mapping is committed only on success; gates completed before an error are not rolled back.

As in from_circuit, terminal measurements are ignored. A measured qubit used by a later gate or Reset is rejected before the state is changed. Independent gates, repeated measurements, Barrier, Delay, and Store are allowed.

This state-level entry point ignores terminal measurement declarations, matching from_circuit. Use run_circuit when runtime classical measurement values are required.

Source

pub fn run_circuit( circuit: &Circuit, ) -> Result<CircuitExecutionResult, QisError>

Executes a Clifford circuit and returns both the final state and runtime classical data.

Returns a CircuitExecutionResult containing:

§Supported instructions

Same quantum gates as from_circuit. Unlike from_circuit, this method executes MeasureBit, MeasureBits, and Store: measurements collapse the state immediately and write runtime classical data. Control-flow gates are not supported.

§Example
use cqlib_core::circuit::{Circuit, ClassicalExpr, ClassicalType, Qubit};
use cqlib_core::qis::{RuntimeValue, StabilizerState};

let mut c = Circuit::new(1);
c.x(Qubit::new(0)).unwrap();

// `measure` creates an immutable runtime value.
let measured = c.measure(Qubit::new(0)).unwrap();

// `store` can copy or transform measured values into mutable variables.
let flag = c.var(ClassicalType::Bool);
c.store(flag, ClassicalExpr::bit_to_bool(measured.expr()).unwrap()).unwrap();

let result = StabilizerState::run_circuit(&c).unwrap();
assert_eq!(result.classical.value(measured.value()), Some(&RuntimeValue::Bit(true)));
assert_eq!(result.classical.var(flag), Some(&RuntimeValue::Bool(true)));
Source

pub fn apply_standard_gate( &mut self, gate: StandardGate, qubits: &[usize], params: &[f64], ) -> Result<(), QisError>

Applies a standard gate to the stabilizer tableau.

Returns QisError::NonCliffordGate for gates outside the Clifford set.

Source

pub fn get_stabilizers(&self) -> Vec<PauliString>

There are n stabilizer generators (rows n..2n).

Source

pub fn get_destabilizers(&self) -> Vec<PauliString>

Returns the destabilizer generators as PauliStrings.

Source

pub fn pauli_expectation(&self, pauli: &PauliString) -> Result<i32, QisError>

Returns the expectation value ⟨ψ|P|ψ⟩ for a Pauli string pauli.

Uses GF(2) Gaussian elimination over the symplectic representation of the stabilizer generators to determine whether pauli is in the stabilizer group (expectation +1), the negative stabilizer group (expectation -1), or neither (expectation 0).

This correctly handles products of generators, not just individual generators.

Source

pub fn to_stim_format(&self) -> String

Exports the stabilizer tableau in Stim-compatible text format.

Trait Implementations§

Source§

impl Clone for StabilizerState

Source§

fn clone(&self) -> Self

O(n²) deep copy — clones the flat tableau, phases, and RNG state.

The RNG is cloned (not re-seeded) so that parallel samples produced from independent clones diverge deterministically from the same seed, which is required for reproducible multi-shot sampling with Rayon.

1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StabilizerState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V