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: usizeNumber of qubits.
Implementations§
Source§impl StabilizerState
impl StabilizerState
Sourcepub fn new(n: usize) -> Self
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(rowi): X on qubiti, identity elsewhere, phase +1. - Stabilizer
i(rown+i): Z on qubiti, identity elsewhere, phase +1.
§Arguments
n— number of qubits
Sourcepub fn apply_cx(
&mut self,
control: usize,
target: usize,
) -> Result<(), QisError>
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]
Sourcepub fn apply_swap(&mut self, q0: usize, q1: usize) -> Result<(), QisError>
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.
Sourcepub fn apply_cz(&mut self, q0: usize, q1: usize) -> Result<(), QisError>
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.
Sourcepub fn apply_cy(
&mut self,
control: usize,
target: usize,
) -> Result<(), QisError>
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†).
Sourcepub fn num_qubits(&self) -> usize
pub fn num_qubits(&self) -> usize
Returns the number of qubits.
Sourcepub fn apply_h(&mut self, qubit: usize) -> Result<(), QisError>
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]andz[i][qubit]
Sourcepub fn apply_s(&mut self, qubit: usize) -> Result<(), QisError>
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.
Sourcepub fn apply_sdg(&mut self, qubit: usize) -> Result<(), QisError>
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]
Sourcepub fn apply_x(&mut self, qubit: usize) -> Result<(), QisError>
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.
Sourcepub fn apply_z(&mut self, qubit: usize) -> Result<(), QisError>
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.
Sourcepub fn apply_y(&mut self, qubit: usize) -> Result<(), QisError>
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.
Sourcepub fn apply_x2p(&mut self, qubit: usize) -> Result<(), QisError>
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]
Sourcepub fn apply_x2m(&mut self, qubit: usize) -> Result<(), QisError>
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]
Sourcepub fn apply_y2p(&mut self, qubit: usize) -> Result<(), QisError>
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]
Sourcepub fn apply_y2m(&mut self, qubit: usize) -> Result<(), QisError>
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]
Sourcepub fn measure(&mut self, qubit: usize) -> Result<bool, QisError>
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:
- Find any stabilizer row
p(indexn..2n) withx[p][qubit] = 1. - XOR row
pinto every other row that also hasx[.][qubit] = 1. - Move row
pto its paired destabilizer rowp - n. - Replace stabilizer row
pwith±Z_qubit, where the sign is random.
Deterministic case — all stabilizers commute with Z_qubit:
- Compute the product of destabilizer rows
i(for which the paired stabilizern+ihasx[n+i][qubit] = 1) into a scratch accumulator. - The measurement outcome is the phase of the scratch row.
Sourcepub fn measure_all(&mut self) -> Outcome
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.
Sourcepub fn reset(&mut self, qubit: usize) -> Result<(), QisError>
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⟩) = 1Sourcepub fn probability_of(&self, bits: &[bool]) -> Result<f64, QisError>
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)wherekis the number of qubits with random outcomes, if the bitstring is in the support.Err(QubitMismatch)ifbits.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);Sourcepub fn probabilities(&self) -> Result<Vec<f64>, QisError>
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⟩Sourcepub fn sample_shots(&self, shots: usize) -> Vec<Outcome>
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)); }Sourcepub fn sample_shots_with_seed(
&self,
shots: usize,
seed: Option<u64>,
) -> Vec<Outcome>
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.
Sourcepub fn sample(
&self,
measurement: &Measurement,
shots: usize,
) -> Result<ExecutionResult, QisError>
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 bitiin eachOutcome.Outcome::to_bitstringdisplays the most-significant result bit first, so string order is the reverse ofmeasurement.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"));Sourcepub fn sample_with_seed(
&self,
measurement: &Measurement,
shots: usize,
seed: Option<u64>,
) -> Result<ExecutionResult, QisError>
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.
Sourcepub fn probs(
&self,
measurement: &Measurement,
) -> Result<HashMap<Outcome, f64>, QisError>
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.
Sourcepub fn from_circuit(circuit: &Circuit) -> Result<Self, QisError>
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,Storeare 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);Sourcepub fn apply_circuit(&mut self, input_circuit: &Circuit) -> Result<(), QisError>
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.
Sourcepub fn run_circuit(
circuit: &Circuit,
) -> Result<CircuitExecutionResult, QisError>
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:
state: the finalStabilizerStateafter all operationsclassical: measurement results and mutable variables indexed bycrate::circuit::ClassicalValueandcrate::circuit::ClassicalVar
§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)));Sourcepub fn apply_standard_gate(
&mut self,
gate: StandardGate,
qubits: &[usize],
params: &[f64],
) -> Result<(), QisError>
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.
Sourcepub fn get_stabilizers(&self) -> Vec<PauliString>
pub fn get_stabilizers(&self) -> Vec<PauliString>
There are n stabilizer generators (rows n..2n).
Sourcepub fn get_destabilizers(&self) -> Vec<PauliString>
pub fn get_destabilizers(&self) -> Vec<PauliString>
Returns the destabilizer generators as PauliStrings.
Sourcepub fn pauli_expectation(&self, pauli: &PauliString) -> Result<i32, QisError>
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.
Sourcepub fn to_stim_format(&self) -> String
pub fn to_stim_format(&self) -> String
Exports the stabilizer tableau in Stim-compatible text format.
Trait Implementations§
Source§impl Clone for StabilizerState
impl Clone for StabilizerState
Source§fn clone(&self) -> Self
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)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for StabilizerState
impl RefUnwindSafe for StabilizerState
impl Send for StabilizerState
impl Sync for StabilizerState
impl Unpin for StabilizerState
impl UnsafeUnpin for StabilizerState
impl UnwindSafe for StabilizerState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
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
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
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
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.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
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.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
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.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
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.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
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.