CouplingMap

Struct CouplingMap 

Source
pub struct CouplingMap { /* private fields */ }
Expand description

Coupling map representing the connectivity graph of a quantum device

Implementations§

Source§

impl CouplingMap

Source

pub fn new(num_qubits: usize) -> Self

Create a new coupling map with the specified number of qubits

Source

pub fn add_edge(&mut self, qubit1: usize, qubit2: usize)

Add a bidirectional edge between two qubits

Source

pub fn are_connected(&self, qubit1: usize, qubit2: usize) -> bool

Check if two qubits are directly connected

Source

pub fn neighbors(&self, qubit: usize) -> &[usize]

Get the neighbors of a qubit

Source

pub fn num_qubits(&self) -> usize

Get the number of qubits

Examples found in repository?
examples/routing_demo.rs (line 50)
44fn demo_linear_coupling(circuit: &Circuit<4>) -> quantrs2_core::error::QuantRS2Result<()> {
45    println!("--- Linear Device (0-1-2-3) ---");
46
47    let coupling_map = CouplingMap::linear(4);
48    println!(
49        "Coupling map: linear chain with {} qubits",
50        coupling_map.num_qubits()
51    );
52    println!("Edges: {:?}", coupling_map.edges());
53
54    // Test SABRE routing
55    let router = CircuitRouter::new(RoutingStrategy::Sabre, coupling_map.clone());
56    let routed = router.route(circuit)?;
57
58    println!("\nSABRE Routing Results:");
59    println!("  Total gates after routing: {}", routed.num_gates());
60    println!("  SWAP gates inserted: {}", routed.num_swaps());
61    println!(
62        "  Routing overhead: {:.2}%",
63        routed.routing_overhead() * 100.0
64    );
65    println!("  Final mapping: {:?}", routed.get_mapping());
66
67    let stats = routed.statistics();
68    println!("  Circuit depth: {}", stats.circuit_depth);
69    println!(
70        "  Gate breakdown: {} single, {} two-qubit, {} SWAPs",
71        stats.single_qubit_gates, stats.two_qubit_gates, stats.swap_gates
72    );
73
74    // Test Lookahead routing
75    let lookahead_router =
76        CircuitRouter::new(RoutingStrategy::Lookahead { depth: 5 }, coupling_map);
77    let routed_lookahead = lookahead_router.route(circuit)?;
78
79    println!("\nLookahead Routing Results:");
80    println!(
81        "  Total gates after routing: {}",
82        routed_lookahead.num_gates()
83    );
84    println!("  SWAP gates inserted: {}", routed_lookahead.num_swaps());
85    println!(
86        "  Routing overhead: {:.2}%",
87        routed_lookahead.routing_overhead() * 100.0
88    );
89
90    println!();
91    Ok(())
92}
93
94fn demo_grid_coupling(circuit: &Circuit<4>) -> quantrs2_core::error::QuantRS2Result<()> {
95    println!("--- 2x2 Grid Device ---");
96
97    let coupling_map = CouplingMap::grid(2, 2);
98    println!(
99        "Coupling map: 2x2 grid with {} qubits",
100        coupling_map.num_qubits()
101    );
102    println!("Edges: {:?}", coupling_map.edges());
103
104    let router = CircuitRouter::new(RoutingStrategy::Sabre, coupling_map);
105    let routed = router.route(circuit)?;
106
107    println!("\nSABRE Routing Results:");
108    println!("  Total gates after routing: {}", routed.num_gates());
109    println!("  SWAP gates inserted: {}", routed.num_swaps());
110    println!(
111        "  Routing overhead: {:.2}%",
112        routed.routing_overhead() * 100.0
113    );
114    println!("  Final mapping: {:?}", routed.get_mapping());
115
116    println!();
117    Ok(())
118}
119
120fn demo_custom_device(circuit: &Circuit<4>) -> quantrs2_core::error::QuantRS2Result<()> {
121    println!("--- Custom Device (Star topology) ---");
122
123    // Create a star topology: center qubit (0) connected to all others
124    let edges = [(0, 1), (0, 2), (0, 3)];
125    let coupling_map = CouplingMap::from_edges(4, &edges);
126
127    println!(
128        "Coupling map: star topology with {} qubits",
129        coupling_map.num_qubits()
130    );
131    println!("Edges: {:?}", coupling_map.edges());
132    println!("Diameter: {}", coupling_map.diameter());
133
134    let router = CircuitRouter::new(RoutingStrategy::Sabre, coupling_map);
135    let routed = router.route(circuit)?;
136
137    println!("\nSABRE Routing Results:");
138    println!("  Total gates after routing: {}", routed.num_gates());
139    println!("  SWAP gates inserted: {}", routed.num_swaps());
140    println!(
141        "  Routing overhead: {:.2}%",
142        routed.routing_overhead() * 100.0
143    );
144    println!("  Final mapping: {:?}", routed.get_mapping());
145
146    // Test stochastic routing for comparison
147    let stochastic_router = CircuitRouter::new(
148        RoutingStrategy::Stochastic { trials: 3 },
149        CouplingMap::from_edges(4, &edges),
150    );
151    let routed_stochastic = stochastic_router.route(circuit)?;
152
153    println!("\nStochastic Routing Results (3 trials):");
154    println!(
155        "  Total gates after routing: {}",
156        routed_stochastic.num_gates()
157    );
158    println!("  SWAP gates inserted: {}", routed_stochastic.num_swaps());
159    println!(
160        "  Routing overhead: {:.2}%",
161        routed_stochastic.routing_overhead() * 100.0
162    );
163
164    println!();
165    Ok(())
166}
Source

pub fn edges(&self) -> Vec<(usize, usize)>

Get all edges as pairs

Examples found in repository?
examples/routing_demo.rs (line 52)
44fn demo_linear_coupling(circuit: &Circuit<4>) -> quantrs2_core::error::QuantRS2Result<()> {
45    println!("--- Linear Device (0-1-2-3) ---");
46
47    let coupling_map = CouplingMap::linear(4);
48    println!(
49        "Coupling map: linear chain with {} qubits",
50        coupling_map.num_qubits()
51    );
52    println!("Edges: {:?}", coupling_map.edges());
53
54    // Test SABRE routing
55    let router = CircuitRouter::new(RoutingStrategy::Sabre, coupling_map.clone());
56    let routed = router.route(circuit)?;
57
58    println!("\nSABRE Routing Results:");
59    println!("  Total gates after routing: {}", routed.num_gates());
60    println!("  SWAP gates inserted: {}", routed.num_swaps());
61    println!(
62        "  Routing overhead: {:.2}%",
63        routed.routing_overhead() * 100.0
64    );
65    println!("  Final mapping: {:?}", routed.get_mapping());
66
67    let stats = routed.statistics();
68    println!("  Circuit depth: {}", stats.circuit_depth);
69    println!(
70        "  Gate breakdown: {} single, {} two-qubit, {} SWAPs",
71        stats.single_qubit_gates, stats.two_qubit_gates, stats.swap_gates
72    );
73
74    // Test Lookahead routing
75    let lookahead_router =
76        CircuitRouter::new(RoutingStrategy::Lookahead { depth: 5 }, coupling_map);
77    let routed_lookahead = lookahead_router.route(circuit)?;
78
79    println!("\nLookahead Routing Results:");
80    println!(
81        "  Total gates after routing: {}",
82        routed_lookahead.num_gates()
83    );
84    println!("  SWAP gates inserted: {}", routed_lookahead.num_swaps());
85    println!(
86        "  Routing overhead: {:.2}%",
87        routed_lookahead.routing_overhead() * 100.0
88    );
89
90    println!();
91    Ok(())
92}
93
94fn demo_grid_coupling(circuit: &Circuit<4>) -> quantrs2_core::error::QuantRS2Result<()> {
95    println!("--- 2x2 Grid Device ---");
96
97    let coupling_map = CouplingMap::grid(2, 2);
98    println!(
99        "Coupling map: 2x2 grid with {} qubits",
100        coupling_map.num_qubits()
101    );
102    println!("Edges: {:?}", coupling_map.edges());
103
104    let router = CircuitRouter::new(RoutingStrategy::Sabre, coupling_map);
105    let routed = router.route(circuit)?;
106
107    println!("\nSABRE Routing Results:");
108    println!("  Total gates after routing: {}", routed.num_gates());
109    println!("  SWAP gates inserted: {}", routed.num_swaps());
110    println!(
111        "  Routing overhead: {:.2}%",
112        routed.routing_overhead() * 100.0
113    );
114    println!("  Final mapping: {:?}", routed.get_mapping());
115
116    println!();
117    Ok(())
118}
119
120fn demo_custom_device(circuit: &Circuit<4>) -> quantrs2_core::error::QuantRS2Result<()> {
121    println!("--- Custom Device (Star topology) ---");
122
123    // Create a star topology: center qubit (0) connected to all others
124    let edges = [(0, 1), (0, 2), (0, 3)];
125    let coupling_map = CouplingMap::from_edges(4, &edges);
126
127    println!(
128        "Coupling map: star topology with {} qubits",
129        coupling_map.num_qubits()
130    );
131    println!("Edges: {:?}", coupling_map.edges());
132    println!("Diameter: {}", coupling_map.diameter());
133
134    let router = CircuitRouter::new(RoutingStrategy::Sabre, coupling_map);
135    let routed = router.route(circuit)?;
136
137    println!("\nSABRE Routing Results:");
138    println!("  Total gates after routing: {}", routed.num_gates());
139    println!("  SWAP gates inserted: {}", routed.num_swaps());
140    println!(
141        "  Routing overhead: {:.2}%",
142        routed.routing_overhead() * 100.0
143    );
144    println!("  Final mapping: {:?}", routed.get_mapping());
145
146    // Test stochastic routing for comparison
147    let stochastic_router = CircuitRouter::new(
148        RoutingStrategy::Stochastic { trials: 3 },
149        CouplingMap::from_edges(4, &edges),
150    );
151    let routed_stochastic = stochastic_router.route(circuit)?;
152
153    println!("\nStochastic Routing Results (3 trials):");
154    println!(
155        "  Total gates after routing: {}",
156        routed_stochastic.num_gates()
157    );
158    println!("  SWAP gates inserted: {}", routed_stochastic.num_swaps());
159    println!(
160        "  Routing overhead: {:.2}%",
161        routed_stochastic.routing_overhead() * 100.0
162    );
163
164    println!();
165    Ok(())
166}
Source

pub fn distance(&self, qubit1: usize, qubit2: usize) -> Distance

Compute the distance between two qubits using BFS

Source

pub fn compute_distances(&mut self)

Pre-compute all-pairs shortest distances

Source

pub fn shortest_path(&self, start: usize, end: usize) -> Option<Vec<usize>>

Get the shortest path between two qubits

Source

pub fn is_connected(&self) -> bool

Check if the graph is connected

Source

pub fn diameter(&self) -> Distance

Get the diameter of the graph (maximum distance between any two nodes)

Examples found in repository?
examples/routing_demo.rs (line 132)
120fn demo_custom_device(circuit: &Circuit<4>) -> quantrs2_core::error::QuantRS2Result<()> {
121    println!("--- Custom Device (Star topology) ---");
122
123    // Create a star topology: center qubit (0) connected to all others
124    let edges = [(0, 1), (0, 2), (0, 3)];
125    let coupling_map = CouplingMap::from_edges(4, &edges);
126
127    println!(
128        "Coupling map: star topology with {} qubits",
129        coupling_map.num_qubits()
130    );
131    println!("Edges: {:?}", coupling_map.edges());
132    println!("Diameter: {}", coupling_map.diameter());
133
134    let router = CircuitRouter::new(RoutingStrategy::Sabre, coupling_map);
135    let routed = router.route(circuit)?;
136
137    println!("\nSABRE Routing Results:");
138    println!("  Total gates after routing: {}", routed.num_gates());
139    println!("  SWAP gates inserted: {}", routed.num_swaps());
140    println!(
141        "  Routing overhead: {:.2}%",
142        routed.routing_overhead() * 100.0
143    );
144    println!("  Final mapping: {:?}", routed.get_mapping());
145
146    // Test stochastic routing for comparison
147    let stochastic_router = CircuitRouter::new(
148        RoutingStrategy::Stochastic { trials: 3 },
149        CouplingMap::from_edges(4, &edges),
150    );
151    let routed_stochastic = stochastic_router.route(circuit)?;
152
153    println!("\nStochastic Routing Results (3 trials):");
154    println!(
155        "  Total gates after routing: {}",
156        routed_stochastic.num_gates()
157    );
158    println!("  SWAP gates inserted: {}", routed_stochastic.num_swaps());
159    println!(
160        "  Routing overhead: {:.2}%",
161        routed_stochastic.routing_overhead() * 100.0
162    );
163
164    println!();
165    Ok(())
166}
Source

pub fn linear(num_qubits: usize) -> Self

Create common device topologies Linear topology (1D chain)

Examples found in repository?
examples/noise_optimization_demo.rs (line 87)
83fn demo_ibm_noise(circuit: &Circuit<4>) -> quantrs2_core::error::QuantRS2Result<()> {
84    println!("--- IBM-like Noise Model ---");
85
86    let noise_model = NoiseModel::ibm_like(4);
87    let coupling_map = CouplingMap::linear(4);
88    let optimizer = NoiseAwareOptimizer::new(noise_model.clone()).with_coupling_map(coupling_map);
89
90    println!("IBM-like noise characteristics:");
91    println!(
92        "  Single-qubit error rate: {:.2e}",
93        noise_model.single_qubit_error(0)
94    );
95    println!(
96        "  Two-qubit error rate (adjacent): {:.2e}",
97        noise_model.two_qubit_error(0, 1)
98    );
99    println!("  Hadamard gate time: {:.1} ns", noise_model.gate_time("H"));
100    println!("  CNOT gate time: {:.1} ns", noise_model.gate_time("CNOT"));
101
102    let original_fidelity = optimizer.estimate_fidelity(circuit);
103    println!("\nOriginal circuit fidelity: {:.4}", original_fidelity);
104
105    let optimized = optimizer.optimize(circuit)?;
106    let optimized_fidelity = optimizer.estimate_fidelity(&optimized);
107    println!("Optimized circuit fidelity: {:.4}", optimized_fidelity);
108
109    println!("Available optimization passes:");
110    for pass in optimizer.get_passes() {
111        println!("  - {}", pass.name());
112    }
113
114    println!();
115    Ok(())
116}
117
118fn demo_noise_aware_cost_model(circuit: &Circuit<4>) -> quantrs2_core::error::QuantRS2Result<()> {
119    println!("--- Noise-Aware Cost Analysis ---");
120
121    let uniform_noise = NoiseModel::uniform(4);
122    let ibm_noise = NoiseModel::ibm_like(4);
123
124    let uniform_cost_model = NoiseAwareCostModel::new(uniform_noise);
125    let ibm_cost_model = NoiseAwareCostModel::new(ibm_noise);
126
127    let uniform_cost = uniform_cost_model.circuit_cost(circuit);
128    let ibm_cost = ibm_cost_model.circuit_cost(circuit);
129
130    println!("Circuit costs with different noise models:");
131    println!("  Uniform noise model: {:.2}", uniform_cost);
132    println!("  IBM-like noise model: {:.2}", ibm_cost);
133
134    // Analyze individual gate costs
135    println!("\nGate-by-gate cost analysis (IBM model):");
136    for (i, gate) in circuit.gates().iter().enumerate() {
137        let gate_cost = ibm_cost_model.gate_cost(gate.as_ref());
138        println!("  Gate {}: {} - Cost: {:.2}", i, gate.name(), gate_cost);
139    }
140
141    println!();
142    Ok(())
143}
144
145fn demo_noise_optimization_passes(
146    circuit: &Circuit<4>,
147) -> quantrs2_core::error::QuantRS2Result<()> {
148    println!("--- Individual Optimization Passes ---");
149
150    let noise_model = NoiseModel::ibm_like(4);
151    let coupling_map = CouplingMap::linear(4);
152
153    // Test coherence optimization
154    let coherence_opt = CoherenceOptimization::new(noise_model.clone());
155    let cost_model = NoiseAwareCostModel::new(noise_model.clone());
156
157    if coherence_opt.should_apply() {
158        let coherence_result = coherence_opt.apply(circuit, &cost_model)?;
159        println!("✓ Coherence optimization applied");
160        println!("  Original gates: {}", circuit.num_gates());
161        println!("  After coherence opt: {}", coherence_result.num_gates());
162    }
163
164    // Test noise-aware mapping
165    let mapping_opt = NoiseAwareMapping::new(noise_model.clone(), coupling_map.clone());
166    if mapping_opt.should_apply() {
167        let mapping_result = mapping_opt.apply(circuit, &cost_model)?;
168        println!("✓ Noise-aware mapping applied");
169        println!("  Original gates: {}", circuit.num_gates());
170        println!("  After mapping opt: {}", mapping_result.num_gates());
171    }
172
173    // Test dynamical decoupling
174    let dd_opt = DynamicalDecoupling::new(noise_model.clone());
175    if dd_opt.should_apply() {
176        let dd_result = dd_opt.apply(circuit, &cost_model)?;
177        println!("✓ Dynamical decoupling applied");
178        println!("  Original gates: {}", circuit.num_gates());
179        println!("  After DD insertion: {}", dd_result.num_gates());
180    }
181
182    println!();
183    Ok(())
184}
More examples
Hide additional examples
examples/routing_demo.rs (line 47)
44fn demo_linear_coupling(circuit: &Circuit<4>) -> quantrs2_core::error::QuantRS2Result<()> {
45    println!("--- Linear Device (0-1-2-3) ---");
46
47    let coupling_map = CouplingMap::linear(4);
48    println!(
49        "Coupling map: linear chain with {} qubits",
50        coupling_map.num_qubits()
51    );
52    println!("Edges: {:?}", coupling_map.edges());
53
54    // Test SABRE routing
55    let router = CircuitRouter::new(RoutingStrategy::Sabre, coupling_map.clone());
56    let routed = router.route(circuit)?;
57
58    println!("\nSABRE Routing Results:");
59    println!("  Total gates after routing: {}", routed.num_gates());
60    println!("  SWAP gates inserted: {}", routed.num_swaps());
61    println!(
62        "  Routing overhead: {:.2}%",
63        routed.routing_overhead() * 100.0
64    );
65    println!("  Final mapping: {:?}", routed.get_mapping());
66
67    let stats = routed.statistics();
68    println!("  Circuit depth: {}", stats.circuit_depth);
69    println!(
70        "  Gate breakdown: {} single, {} two-qubit, {} SWAPs",
71        stats.single_qubit_gates, stats.two_qubit_gates, stats.swap_gates
72    );
73
74    // Test Lookahead routing
75    let lookahead_router =
76        CircuitRouter::new(RoutingStrategy::Lookahead { depth: 5 }, coupling_map);
77    let routed_lookahead = lookahead_router.route(circuit)?;
78
79    println!("\nLookahead Routing Results:");
80    println!(
81        "  Total gates after routing: {}",
82        routed_lookahead.num_gates()
83    );
84    println!("  SWAP gates inserted: {}", routed_lookahead.num_swaps());
85    println!(
86        "  Routing overhead: {:.2}%",
87        routed_lookahead.routing_overhead() * 100.0
88    );
89
90    println!();
91    Ok(())
92}
Source

pub fn ring(num_qubits: usize) -> Self

Ring topology (circular)

Source

pub fn grid(rows: usize, cols: usize) -> Self

Grid topology (2D)

Examples found in repository?
examples/routing_demo.rs (line 97)
94fn demo_grid_coupling(circuit: &Circuit<4>) -> quantrs2_core::error::QuantRS2Result<()> {
95    println!("--- 2x2 Grid Device ---");
96
97    let coupling_map = CouplingMap::grid(2, 2);
98    println!(
99        "Coupling map: 2x2 grid with {} qubits",
100        coupling_map.num_qubits()
101    );
102    println!("Edges: {:?}", coupling_map.edges());
103
104    let router = CircuitRouter::new(RoutingStrategy::Sabre, coupling_map);
105    let routed = router.route(circuit)?;
106
107    println!("\nSABRE Routing Results:");
108    println!("  Total gates after routing: {}", routed.num_gates());
109    println!("  SWAP gates inserted: {}", routed.num_swaps());
110    println!(
111        "  Routing overhead: {:.2}%",
112        routed.routing_overhead() * 100.0
113    );
114    println!("  Final mapping: {:?}", routed.get_mapping());
115
116    println!();
117    Ok(())
118}
Source

pub fn all_to_all(num_qubits: usize) -> Self

All-to-all topology (complete graph)

Source

pub fn ibm_lagos() -> Self

IBM Lagos device topology

Source

pub fn ibm_nairobi() -> Self

IBM Nairobi device topology

Source

pub fn google_sycamore() -> Self

Google Sycamore-like device topology

Source

pub fn from_edges(num_qubits: usize, edges: &[(usize, usize)]) -> Self

Load coupling map from adjacency list

Examples found in repository?
examples/routing_demo.rs (line 125)
120fn demo_custom_device(circuit: &Circuit<4>) -> quantrs2_core::error::QuantRS2Result<()> {
121    println!("--- Custom Device (Star topology) ---");
122
123    // Create a star topology: center qubit (0) connected to all others
124    let edges = [(0, 1), (0, 2), (0, 3)];
125    let coupling_map = CouplingMap::from_edges(4, &edges);
126
127    println!(
128        "Coupling map: star topology with {} qubits",
129        coupling_map.num_qubits()
130    );
131    println!("Edges: {:?}", coupling_map.edges());
132    println!("Diameter: {}", coupling_map.diameter());
133
134    let router = CircuitRouter::new(RoutingStrategy::Sabre, coupling_map);
135    let routed = router.route(circuit)?;
136
137    println!("\nSABRE Routing Results:");
138    println!("  Total gates after routing: {}", routed.num_gates());
139    println!("  SWAP gates inserted: {}", routed.num_swaps());
140    println!(
141        "  Routing overhead: {:.2}%",
142        routed.routing_overhead() * 100.0
143    );
144    println!("  Final mapping: {:?}", routed.get_mapping());
145
146    // Test stochastic routing for comparison
147    let stochastic_router = CircuitRouter::new(
148        RoutingStrategy::Stochastic { trials: 3 },
149        CouplingMap::from_edges(4, &edges),
150    );
151    let routed_stochastic = stochastic_router.route(circuit)?;
152
153    println!("\nStochastic Routing Results (3 trials):");
154    println!(
155        "  Total gates after routing: {}",
156        routed_stochastic.num_gates()
157    );
158    println!("  SWAP gates inserted: {}", routed_stochastic.num_swaps());
159    println!(
160        "  Routing overhead: {:.2}%",
161        routed_stochastic.routing_overhead() * 100.0
162    );
163
164    println!();
165    Ok(())
166}

Trait Implementations§

Source§

impl Clone for CouplingMap

Source§

fn clone(&self) -> CouplingMap

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CouplingMap

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for CouplingMap

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for CouplingMap

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for CouplingMap

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Ungil for T
where T: Send,