pub struct CouplingMap { /* private fields */ }
Expand description
Coupling map representing the connectivity graph of a quantum device
Implementations§
Source§impl CouplingMap
impl CouplingMap
Sourcepub fn new(num_qubits: usize) -> Self
pub fn new(num_qubits: usize) -> Self
Create a new coupling map with the specified number of qubits
Sourcepub fn add_edge(&mut self, qubit1: usize, qubit2: usize)
pub fn add_edge(&mut self, qubit1: usize, qubit2: usize)
Add a bidirectional edge between two qubits
Sourcepub fn are_connected(&self, qubit1: usize, qubit2: usize) -> bool
pub fn are_connected(&self, qubit1: usize, qubit2: usize) -> bool
Check if two qubits are directly connected
Sourcepub fn num_qubits(&self) -> usize
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}
Sourcepub fn edges(&self) -> Vec<(usize, usize)>
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}
Sourcepub fn distance(&self, qubit1: usize, qubit2: usize) -> Distance
pub fn distance(&self, qubit1: usize, qubit2: usize) -> Distance
Compute the distance between two qubits using BFS
Sourcepub fn compute_distances(&mut self)
pub fn compute_distances(&mut self)
Pre-compute all-pairs shortest distances
Sourcepub fn shortest_path(&self, start: usize, end: usize) -> Option<Vec<usize>>
pub fn shortest_path(&self, start: usize, end: usize) -> Option<Vec<usize>>
Get the shortest path between two qubits
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if the graph is connected
Sourcepub fn diameter(&self) -> Distance
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}
Sourcepub fn linear(num_qubits: usize) -> Self
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
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}
Sourcepub fn grid(rows: usize, cols: usize) -> Self
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}
Sourcepub fn all_to_all(num_qubits: usize) -> Self
pub fn all_to_all(num_qubits: usize) -> Self
All-to-all topology (complete graph)
Sourcepub fn ibm_nairobi() -> Self
pub fn ibm_nairobi() -> Self
IBM Nairobi device topology
Sourcepub fn google_sycamore() -> Self
pub fn google_sycamore() -> Self
Google Sycamore-like device topology
Sourcepub fn from_edges(num_qubits: usize, edges: &[(usize, usize)]) -> Self
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
impl Clone for CouplingMap
Source§fn clone(&self) -> CouplingMap
fn clone(&self) -> CouplingMap
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CouplingMap
impl Debug for CouplingMap
Source§impl Default for CouplingMap
impl Default for CouplingMap
Source§impl<'de> Deserialize<'de> for CouplingMap
impl<'de> Deserialize<'de> for CouplingMap
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CouplingMap
impl RefUnwindSafe for CouplingMap
impl Send for CouplingMap
impl Sync for CouplingMap
impl Unpin for CouplingMap
impl UnwindSafe for CouplingMap
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.