pub struct PulseSchedule {
pub instructions: Vec<(f64, PulseInstruction)>,
pub duration: f64,
pub channels: Vec<Channel>,
}
Expand description
Pulse schedule representing a quantum operation
Fields§
§instructions: Vec<(f64, PulseInstruction)>
Instructions in the schedule
duration: f64
Total duration
channels: Vec<Channel>
Channels used
Implementations§
Source§impl PulseSchedule
impl PulseSchedule
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new empty schedule
Examples found in repository?
examples/pulse_demo.rs (line 71)
67fn demo_pulse_schedules() -> quantrs2_core::error::QuantRS2Result<()> {
68 println!("--- Pulse Schedule Construction ---");
69
70 let sample_rate = 1.0;
71 let mut schedule = PulseSchedule::new();
72
73 // Create waveforms
74 let pi_pulse = Waveform::gaussian(0.5, 10.0, 40.0, sample_rate);
75 let pi2_pulse = Waveform::gaussian(0.25, 10.0, 40.0, sample_rate);
76 let cr_pulse = Waveform::square(0.1, 200.0, sample_rate);
77
78 // Build schedule for a simple circuit
79 let mut time = 0.0;
80
81 // X gate on qubit 0
82 schedule.add_instruction(
83 time,
84 PulseInstruction::Play {
85 waveform: pi_pulse.clone(),
86 channel: Channel::Drive(0),
87 phase: 0.0,
88 },
89 );
90 time += 40.0;
91
92 // Delay
93 schedule.add_instruction(
94 time,
95 PulseInstruction::Delay {
96 duration: 20.0,
97 channels: vec![Channel::Drive(0), Channel::Drive(1)],
98 },
99 );
100 time += 20.0;
101
102 // CNOT using cross-resonance
103 schedule.add_instruction(
104 time,
105 PulseInstruction::Play {
106 waveform: cr_pulse,
107 channel: Channel::Control(0, 1),
108 phase: 0.0,
109 },
110 );
111
112 // Echo pulse on target
113 schedule.add_instruction(
114 time + 100.0,
115 PulseInstruction::Play {
116 waveform: pi_pulse.clone(),
117 channel: Channel::Drive(1),
118 phase: PI,
119 },
120 );
121 time += 200.0;
122
123 // Measurement
124 schedule.add_instruction(
125 time,
126 PulseInstruction::Acquire {
127 duration: 1000.0,
128 channel: Channel::Measure(0),
129 memory_slot: 0,
130 },
131 );
132
133 println!("Built pulse schedule:");
134 println!(" Total duration: {} ns", schedule.duration);
135 println!(" Instructions: {}", schedule.instructions.len());
136 println!(" Channels used: {}", schedule.channels.len());
137
138 println!("\nSchedule timeline:");
139 for (time, instruction) in &schedule.instructions {
140 match instruction {
141 PulseInstruction::Play { channel, .. } => {
142 println!(" {:6.1} ns: Play on {:?}", time, channel);
143 }
144 PulseInstruction::Delay { duration, .. } => {
145 println!(" {:6.1} ns: Delay {} ns", time, duration);
146 }
147 PulseInstruction::Acquire { channel, .. } => {
148 println!(" {:6.1} ns: Acquire on {:?}", time, channel);
149 }
150 _ => {}
151 }
152 }
153
154 println!();
155 Ok(())
156}
157
158fn demo_pulse_compilation() -> quantrs2_core::error::QuantRS2Result<()> {
159 println!("--- Circuit to Pulse Compilation ---");
160
161 // Create device configuration
162 let device_config = DeviceConfig::default_config(4);
163 println!("Device configuration:");
164 println!(" Qubits: 4");
165 println!(" Qubit frequencies: ~5 GHz");
166 println!(" Sample rate: {} GS/s", device_config.sample_rate);
167
168 // Create compiler
169 let compiler = PulseCompiler::new(device_config);
170
171 // Create a simple circuit
172 let mut circuit = Circuit::<4>::new();
173 circuit.add_gate(Hadamard { target: QubitId(0) })?;
174 circuit.add_gate(CNOT {
175 control: QubitId(0),
176 target: QubitId(1),
177 })?;
178 circuit.add_gate(RotationZ {
179 target: QubitId(1),
180 theta: PI / 4.0,
181 })?;
182
183 println!("\nCompiling circuit:");
184 for (i, gate) in circuit.gates().iter().enumerate() {
185 println!(" {}: {}", i, gate.name());
186 }
187
188 // Compile to pulses
189 let pulse_schedule = compiler.compile(&circuit)?;
190
191 println!("\nCompiled pulse schedule:");
192 println!(" Duration: {} ns", pulse_schedule.duration);
193 println!(" Instructions: {}", pulse_schedule.instructions.len());
194
195 // Show channel usage
196 let mut channel_usage = std::collections::HashMap::new();
197 for (_, instruction) in &pulse_schedule.instructions {
198 match instruction {
199 PulseInstruction::Play { channel, .. } => {
200 *channel_usage.entry(format!("{:?}", channel)).or_insert(0) += 1;
201 }
202 _ => {}
203 }
204 }
205
206 println!("\nChannel usage:");
207 for (channel, count) in channel_usage {
208 println!(" {}: {} pulses", channel, count);
209 }
210
211 println!();
212 Ok(())
213}
214
215fn demo_pulse_calibration() -> quantrs2_core::error::QuantRS2Result<()> {
216 println!("--- Pulse Calibration ---");
217
218 let sample_rate = 1.0;
219
220 // Create calibrations for different rotation angles
221 let angles = vec![PI / 4.0, PI / 2.0, PI, 3.0 * PI / 2.0];
222 let mut calibrations = Vec::new();
223
224 for &angle in &angles {
225 // Calculate pulse amplitude for rotation
226 let amplitude = angle / (2.0 * PI) * 0.5; // Simplified
227 let waveform = Waveform::gaussian(amplitude, 10.0, 40.0, sample_rate);
228
229 let mut schedule = PulseSchedule::new();
230 schedule.add_instruction(
231 0.0,
232 PulseInstruction::Play {
233 waveform,
234 channel: Channel::Drive(0),
235 phase: 0.0,
236 },
237 );
238
239 let mut parameters = std::collections::HashMap::new();
240 parameters.insert("theta".to_string(), angle);
241
242 calibrations.push(PulseCalibration {
243 gate_name: "RZ".to_string(),
244 qubits: vec![QubitId(0)],
245 parameters,
246 schedule,
247 });
248 }
249
250 println!("Created {} calibrations for RZ gate", calibrations.len());
251
252 for calib in &calibrations {
253 let theta = calib.parameters.get("theta").unwrap();
254 println!(
255 " RZ(θ={:.3}): duration = {} ns",
256 theta, calib.schedule.duration
257 );
258 }
259
260 // Demonstrate calibration interpolation
261 println!("\nCalibration interpolation:");
262 let target_angle = PI / 3.0;
263 println!(" Target angle: π/3");
264 println!(" Would interpolate between π/4 and π/2 calibrations");
265
266 println!();
267 Ok(())
268}
269
270fn demo_pulse_optimization() -> quantrs2_core::error::QuantRS2Result<()> {
271 println!("--- Pulse Optimization ---");
272
273 let sample_rate = 1.0;
274 let optimizer = PulseOptimizer::new();
275
276 // Create initial pulse
277 let mut pulse = Waveform::gaussian(0.5, 15.0, 60.0, sample_rate);
278 println!("Initial pulse:");
279 println!(" Type: Gaussian");
280 println!(" Duration: {} ns", pulse.duration);
281 println!(" Max amplitude: {:.4}", pulse.max_amplitude());
282
283 // Apply DRAG correction
284 optimizer.apply_drag_correction(&mut pulse, 0.1)?;
285 println!("\nAfter DRAG correction:");
286 println!(
287 " Has imaginary component: {}",
288 pulse.samples.iter().any(|s| s.im.abs() > 1e-10)
289 );
290
291 // Create a pulse schedule to optimize
292 let mut schedule = PulseSchedule::new();
293
294 // Add multiple pulses
295 for i in 0..3 {
296 let waveform = Waveform::gaussian(0.4, 12.0, 48.0, sample_rate);
297 schedule.add_instruction(
298 i as f64 * 60.0,
299 PulseInstruction::Play {
300 waveform,
301 channel: Channel::Drive(i),
302 phase: 0.0,
303 },
304 );
305 }
306
307 println!("\nSchedule optimization:");
308 println!(" Original duration: {} ns", schedule.duration);
309
310 // Optimize (placeholder - would do actual optimization)
311 optimizer.optimize(&mut schedule)?;
312
313 println!(
314 " Optimized duration: {} ns (placeholder)",
315 schedule.duration
316 );
317 println!(" Target fidelity: 0.999"); // Placeholder since field is private
318
319 // Demonstrate pulse shaping techniques
320 println!("\nPulse shaping techniques:");
321 println!(" - Gaussian: Smooth envelope, reduced frequency spread");
322 println!(" - DRAG: Reduces leakage to higher levels");
323 println!(" - Cosine: Smooth turn-on/off");
324 println!(" - GRAPE: Optimal control for specific unitaries");
325
326 println!();
327 Ok(())
328}
329
330fn demo_advanced_pulses() -> quantrs2_core::error::QuantRS2Result<()> {
331 println!("--- Advanced Pulse Techniques ---");
332
333 let sample_rate = 2.0; // 2 GS/s for higher resolution
334
335 // Composite pulse for robust gates
336 println!("Composite pulse sequence (BB1):");
337 let mut bb1_schedule = PulseSchedule::new();
338
339 // BB1 sequence: Ry(π/2) - Rx(π) - Ry(3π/2) - Rx(π)
340 let pi2_y = Waveform::gaussian(0.25, 8.0, 32.0, sample_rate);
341 let pi_x = Waveform::gaussian(0.5, 8.0, 32.0, sample_rate);
342 let three_pi2_y = Waveform::gaussian(0.75, 8.0, 32.0, sample_rate);
343
344 let mut time = 0.0;
345
346 bb1_schedule.add_instruction(
347 time,
348 PulseInstruction::Play {
349 waveform: pi2_y,
350 channel: Channel::Drive(0),
351 phase: PI / 2.0, // Y rotation
352 },
353 );
354 time += 32.0;
355
356 bb1_schedule.add_instruction(
357 time,
358 PulseInstruction::Play {
359 waveform: pi_x.clone(),
360 channel: Channel::Drive(0),
361 phase: 0.0, // X rotation
362 },
363 );
364 time += 32.0;
365
366 bb1_schedule.add_instruction(
367 time,
368 PulseInstruction::Play {
369 waveform: three_pi2_y,
370 channel: Channel::Drive(0),
371 phase: PI / 2.0, // Y rotation
372 },
373 );
374 time += 32.0;
375
376 bb1_schedule.add_instruction(
377 time,
378 PulseInstruction::Play {
379 waveform: pi_x,
380 channel: Channel::Drive(0),
381 phase: 0.0, // X rotation
382 },
383 );
384
385 println!(" Total duration: {} ns", bb1_schedule.duration);
386 println!(" Robustness: High (compensates for amplitude errors)");
387
388 // Adiabatic pulses
389 println!("\nAdiabatic pulse:");
390 let mut adiabatic_samples = Vec::new();
391 let duration = 100.0;
392 let n_samples = (duration * sample_rate) as usize;
393
394 for i in 0..n_samples {
395 let t = i as f64 / sample_rate;
396 let normalized_t = t / duration;
397
398 // Tanh profile for adiabatic following
399 let amplitude = 0.5 * ((10.0 * (normalized_t - 0.5)).tanh() + 1.0) / 2.0;
400 adiabatic_samples.push(C64::new(amplitude, 0.0));
401 }
402
403 let adiabatic = Waveform::new(adiabatic_samples, sample_rate);
404 println!(" Duration: {} ns", adiabatic.duration);
405 println!(" Profile: Smooth tanh ramp");
406 println!(" Use case: State transfer with high fidelity");
407
408 Ok(())
409}
Sourcepub fn add_instruction(&mut self, time: f64, instruction: PulseInstruction)
pub fn add_instruction(&mut self, time: f64, instruction: PulseInstruction)
Add an instruction at a specific time
Examples found in repository?
examples/pulse_demo.rs (lines 82-89)
67fn demo_pulse_schedules() -> quantrs2_core::error::QuantRS2Result<()> {
68 println!("--- Pulse Schedule Construction ---");
69
70 let sample_rate = 1.0;
71 let mut schedule = PulseSchedule::new();
72
73 // Create waveforms
74 let pi_pulse = Waveform::gaussian(0.5, 10.0, 40.0, sample_rate);
75 let pi2_pulse = Waveform::gaussian(0.25, 10.0, 40.0, sample_rate);
76 let cr_pulse = Waveform::square(0.1, 200.0, sample_rate);
77
78 // Build schedule for a simple circuit
79 let mut time = 0.0;
80
81 // X gate on qubit 0
82 schedule.add_instruction(
83 time,
84 PulseInstruction::Play {
85 waveform: pi_pulse.clone(),
86 channel: Channel::Drive(0),
87 phase: 0.0,
88 },
89 );
90 time += 40.0;
91
92 // Delay
93 schedule.add_instruction(
94 time,
95 PulseInstruction::Delay {
96 duration: 20.0,
97 channels: vec![Channel::Drive(0), Channel::Drive(1)],
98 },
99 );
100 time += 20.0;
101
102 // CNOT using cross-resonance
103 schedule.add_instruction(
104 time,
105 PulseInstruction::Play {
106 waveform: cr_pulse,
107 channel: Channel::Control(0, 1),
108 phase: 0.0,
109 },
110 );
111
112 // Echo pulse on target
113 schedule.add_instruction(
114 time + 100.0,
115 PulseInstruction::Play {
116 waveform: pi_pulse.clone(),
117 channel: Channel::Drive(1),
118 phase: PI,
119 },
120 );
121 time += 200.0;
122
123 // Measurement
124 schedule.add_instruction(
125 time,
126 PulseInstruction::Acquire {
127 duration: 1000.0,
128 channel: Channel::Measure(0),
129 memory_slot: 0,
130 },
131 );
132
133 println!("Built pulse schedule:");
134 println!(" Total duration: {} ns", schedule.duration);
135 println!(" Instructions: {}", schedule.instructions.len());
136 println!(" Channels used: {}", schedule.channels.len());
137
138 println!("\nSchedule timeline:");
139 for (time, instruction) in &schedule.instructions {
140 match instruction {
141 PulseInstruction::Play { channel, .. } => {
142 println!(" {:6.1} ns: Play on {:?}", time, channel);
143 }
144 PulseInstruction::Delay { duration, .. } => {
145 println!(" {:6.1} ns: Delay {} ns", time, duration);
146 }
147 PulseInstruction::Acquire { channel, .. } => {
148 println!(" {:6.1} ns: Acquire on {:?}", time, channel);
149 }
150 _ => {}
151 }
152 }
153
154 println!();
155 Ok(())
156}
157
158fn demo_pulse_compilation() -> quantrs2_core::error::QuantRS2Result<()> {
159 println!("--- Circuit to Pulse Compilation ---");
160
161 // Create device configuration
162 let device_config = DeviceConfig::default_config(4);
163 println!("Device configuration:");
164 println!(" Qubits: 4");
165 println!(" Qubit frequencies: ~5 GHz");
166 println!(" Sample rate: {} GS/s", device_config.sample_rate);
167
168 // Create compiler
169 let compiler = PulseCompiler::new(device_config);
170
171 // Create a simple circuit
172 let mut circuit = Circuit::<4>::new();
173 circuit.add_gate(Hadamard { target: QubitId(0) })?;
174 circuit.add_gate(CNOT {
175 control: QubitId(0),
176 target: QubitId(1),
177 })?;
178 circuit.add_gate(RotationZ {
179 target: QubitId(1),
180 theta: PI / 4.0,
181 })?;
182
183 println!("\nCompiling circuit:");
184 for (i, gate) in circuit.gates().iter().enumerate() {
185 println!(" {}: {}", i, gate.name());
186 }
187
188 // Compile to pulses
189 let pulse_schedule = compiler.compile(&circuit)?;
190
191 println!("\nCompiled pulse schedule:");
192 println!(" Duration: {} ns", pulse_schedule.duration);
193 println!(" Instructions: {}", pulse_schedule.instructions.len());
194
195 // Show channel usage
196 let mut channel_usage = std::collections::HashMap::new();
197 for (_, instruction) in &pulse_schedule.instructions {
198 match instruction {
199 PulseInstruction::Play { channel, .. } => {
200 *channel_usage.entry(format!("{:?}", channel)).or_insert(0) += 1;
201 }
202 _ => {}
203 }
204 }
205
206 println!("\nChannel usage:");
207 for (channel, count) in channel_usage {
208 println!(" {}: {} pulses", channel, count);
209 }
210
211 println!();
212 Ok(())
213}
214
215fn demo_pulse_calibration() -> quantrs2_core::error::QuantRS2Result<()> {
216 println!("--- Pulse Calibration ---");
217
218 let sample_rate = 1.0;
219
220 // Create calibrations for different rotation angles
221 let angles = vec![PI / 4.0, PI / 2.0, PI, 3.0 * PI / 2.0];
222 let mut calibrations = Vec::new();
223
224 for &angle in &angles {
225 // Calculate pulse amplitude for rotation
226 let amplitude = angle / (2.0 * PI) * 0.5; // Simplified
227 let waveform = Waveform::gaussian(amplitude, 10.0, 40.0, sample_rate);
228
229 let mut schedule = PulseSchedule::new();
230 schedule.add_instruction(
231 0.0,
232 PulseInstruction::Play {
233 waveform,
234 channel: Channel::Drive(0),
235 phase: 0.0,
236 },
237 );
238
239 let mut parameters = std::collections::HashMap::new();
240 parameters.insert("theta".to_string(), angle);
241
242 calibrations.push(PulseCalibration {
243 gate_name: "RZ".to_string(),
244 qubits: vec![QubitId(0)],
245 parameters,
246 schedule,
247 });
248 }
249
250 println!("Created {} calibrations for RZ gate", calibrations.len());
251
252 for calib in &calibrations {
253 let theta = calib.parameters.get("theta").unwrap();
254 println!(
255 " RZ(θ={:.3}): duration = {} ns",
256 theta, calib.schedule.duration
257 );
258 }
259
260 // Demonstrate calibration interpolation
261 println!("\nCalibration interpolation:");
262 let target_angle = PI / 3.0;
263 println!(" Target angle: π/3");
264 println!(" Would interpolate between π/4 and π/2 calibrations");
265
266 println!();
267 Ok(())
268}
269
270fn demo_pulse_optimization() -> quantrs2_core::error::QuantRS2Result<()> {
271 println!("--- Pulse Optimization ---");
272
273 let sample_rate = 1.0;
274 let optimizer = PulseOptimizer::new();
275
276 // Create initial pulse
277 let mut pulse = Waveform::gaussian(0.5, 15.0, 60.0, sample_rate);
278 println!("Initial pulse:");
279 println!(" Type: Gaussian");
280 println!(" Duration: {} ns", pulse.duration);
281 println!(" Max amplitude: {:.4}", pulse.max_amplitude());
282
283 // Apply DRAG correction
284 optimizer.apply_drag_correction(&mut pulse, 0.1)?;
285 println!("\nAfter DRAG correction:");
286 println!(
287 " Has imaginary component: {}",
288 pulse.samples.iter().any(|s| s.im.abs() > 1e-10)
289 );
290
291 // Create a pulse schedule to optimize
292 let mut schedule = PulseSchedule::new();
293
294 // Add multiple pulses
295 for i in 0..3 {
296 let waveform = Waveform::gaussian(0.4, 12.0, 48.0, sample_rate);
297 schedule.add_instruction(
298 i as f64 * 60.0,
299 PulseInstruction::Play {
300 waveform,
301 channel: Channel::Drive(i),
302 phase: 0.0,
303 },
304 );
305 }
306
307 println!("\nSchedule optimization:");
308 println!(" Original duration: {} ns", schedule.duration);
309
310 // Optimize (placeholder - would do actual optimization)
311 optimizer.optimize(&mut schedule)?;
312
313 println!(
314 " Optimized duration: {} ns (placeholder)",
315 schedule.duration
316 );
317 println!(" Target fidelity: 0.999"); // Placeholder since field is private
318
319 // Demonstrate pulse shaping techniques
320 println!("\nPulse shaping techniques:");
321 println!(" - Gaussian: Smooth envelope, reduced frequency spread");
322 println!(" - DRAG: Reduces leakage to higher levels");
323 println!(" - Cosine: Smooth turn-on/off");
324 println!(" - GRAPE: Optimal control for specific unitaries");
325
326 println!();
327 Ok(())
328}
329
330fn demo_advanced_pulses() -> quantrs2_core::error::QuantRS2Result<()> {
331 println!("--- Advanced Pulse Techniques ---");
332
333 let sample_rate = 2.0; // 2 GS/s for higher resolution
334
335 // Composite pulse for robust gates
336 println!("Composite pulse sequence (BB1):");
337 let mut bb1_schedule = PulseSchedule::new();
338
339 // BB1 sequence: Ry(π/2) - Rx(π) - Ry(3π/2) - Rx(π)
340 let pi2_y = Waveform::gaussian(0.25, 8.0, 32.0, sample_rate);
341 let pi_x = Waveform::gaussian(0.5, 8.0, 32.0, sample_rate);
342 let three_pi2_y = Waveform::gaussian(0.75, 8.0, 32.0, sample_rate);
343
344 let mut time = 0.0;
345
346 bb1_schedule.add_instruction(
347 time,
348 PulseInstruction::Play {
349 waveform: pi2_y,
350 channel: Channel::Drive(0),
351 phase: PI / 2.0, // Y rotation
352 },
353 );
354 time += 32.0;
355
356 bb1_schedule.add_instruction(
357 time,
358 PulseInstruction::Play {
359 waveform: pi_x.clone(),
360 channel: Channel::Drive(0),
361 phase: 0.0, // X rotation
362 },
363 );
364 time += 32.0;
365
366 bb1_schedule.add_instruction(
367 time,
368 PulseInstruction::Play {
369 waveform: three_pi2_y,
370 channel: Channel::Drive(0),
371 phase: PI / 2.0, // Y rotation
372 },
373 );
374 time += 32.0;
375
376 bb1_schedule.add_instruction(
377 time,
378 PulseInstruction::Play {
379 waveform: pi_x,
380 channel: Channel::Drive(0),
381 phase: 0.0, // X rotation
382 },
383 );
384
385 println!(" Total duration: {} ns", bb1_schedule.duration);
386 println!(" Robustness: High (compensates for amplitude errors)");
387
388 // Adiabatic pulses
389 println!("\nAdiabatic pulse:");
390 let mut adiabatic_samples = Vec::new();
391 let duration = 100.0;
392 let n_samples = (duration * sample_rate) as usize;
393
394 for i in 0..n_samples {
395 let t = i as f64 / sample_rate;
396 let normalized_t = t / duration;
397
398 // Tanh profile for adiabatic following
399 let amplitude = 0.5 * ((10.0 * (normalized_t - 0.5)).tanh() + 1.0) / 2.0;
400 adiabatic_samples.push(C64::new(amplitude, 0.0));
401 }
402
403 let adiabatic = Waveform::new(adiabatic_samples, sample_rate);
404 println!(" Duration: {} ns", adiabatic.duration);
405 println!(" Profile: Smooth tanh ramp");
406 println!(" Use case: State transfer with high fidelity");
407
408 Ok(())
409}
Sourcepub fn append(&mut self, other: &PulseSchedule, time_offset: f64)
pub fn append(&mut self, other: &PulseSchedule, time_offset: f64)
Merge with another schedule
Sourcepub fn align_parallel(&mut self, schedules: Vec<PulseSchedule>)
pub fn align_parallel(&mut self, schedules: Vec<PulseSchedule>)
Align schedules on multiple channels
Trait Implementations§
Source§impl Clone for PulseSchedule
impl Clone for PulseSchedule
Source§fn clone(&self) -> PulseSchedule
fn clone(&self) -> PulseSchedule
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 moreAuto Trait Implementations§
impl Freeze for PulseSchedule
impl RefUnwindSafe for PulseSchedule
impl Send for PulseSchedule
impl Sync for PulseSchedule
impl Unpin for PulseSchedule
impl UnwindSafe for PulseSchedule
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.