QuantumNAS

Struct QuantumNAS 

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

Main quantum neural architecture search engine

Implementations§

Source§

impl QuantumNAS

Source

pub fn new(strategy: SearchStrategy, search_space: SearchSpace) -> Self

Create a new quantum NAS instance

Examples found in repository?
examples/quantum_nas.rs (line 62)
50fn evolutionary_search_demo() -> Result<()> {
51    // Create search space
52    let search_space = create_default_search_space();
53
54    // Configure evolutionary strategy
55    let strategy = SearchStrategy::Evolutionary {
56        population_size: 20,
57        mutation_rate: 0.2,
58        crossover_rate: 0.7,
59        elitism_ratio: 0.1,
60    };
61
62    let mut nas = QuantumNAS::new(strategy, search_space);
63
64    println!("   Created evolutionary NAS:");
65    println!("   - Population size: 20");
66    println!("   - Mutation rate: 0.2");
67    println!("   - Crossover rate: 0.7");
68    println!("   - Elitism ratio: 0.1");
69
70    // Set evaluation data (synthetic for demo)
71    let eval_data = Array2::from_shape_fn((100, 4), |(i, j)| (i as f64 + j as f64) / 50.0);
72    let eval_labels = Array1::from_shape_fn(100, |i| i % 2);
73    nas.set_evaluation_data(eval_data, eval_labels);
74
75    // Run search
76    println!("\n   Running evolutionary search for 10 generations...");
77    let best_architectures = nas.search(10)?;
78
79    println!("   Search complete!");
80    println!(
81        "   - Best architectures found: {}",
82        best_architectures.len()
83    );
84
85    if let Some(best) = best_architectures.first() {
86        println!("   - Best architecture: {best}");
87        println!("   - Circuit depth: {}", best.metrics.circuit_depth);
88        println!("   - Parameter count: {}", best.metrics.parameter_count);
89
90        if let Some(expressivity) = best.properties.expressivity {
91            println!("   - Expressivity: {expressivity:.3}");
92        }
93    }
94
95    // Show search summary
96    let summary = nas.get_search_summary();
97    println!(
98        "   - Total architectures evaluated: {}",
99        summary.total_architectures_evaluated
100    );
101    println!("   - Pareto front size: {}", summary.pareto_front_size);
102
103    Ok(())
104}
105
106/// Random search baseline demonstration
107fn random_search_demo() -> Result<()> {
108    let search_space = create_default_search_space();
109    let strategy = SearchStrategy::Random { num_samples: 50 };
110
111    let mut nas = QuantumNAS::new(strategy, search_space);
112
113    println!("   Created random search NAS:");
114    println!("   - Number of samples: 50");
115
116    // Generate synthetic evaluation data
117    let eval_data = Array2::from_shape_fn((80, 4), |(i, j)| {
118        0.5f64.mul_add((i as f64).sin(), 0.3 * (j as f64).cos())
119    });
120    let eval_labels = Array1::from_shape_fn(80, |i| usize::from(i % 3 != 0));
121    nas.set_evaluation_data(eval_data, eval_labels);
122
123    println!("\n   Running random search...");
124    let best_architectures = nas.search(50)?;
125
126    println!("   Random search complete!");
127    if let Some(best) = best_architectures.first() {
128        println!("   - Best random architecture: {best}");
129        if let Some(accuracy) = best.metrics.accuracy {
130            println!("   - Accuracy: {accuracy:.3}");
131        }
132    }
133
134    Ok(())
135}
136
137/// Reinforcement learning search demonstration
138fn rl_search_demo() -> Result<()> {
139    let search_space = create_custom_search_space();
140
141    let strategy = SearchStrategy::ReinforcementLearning {
142        agent_type: RLAgentType::PolicyGradient,
143        exploration_rate: 0.3,
144        learning_rate: 0.01,
145    };
146
147    let mut nas = QuantumNAS::new(strategy, search_space);
148
149    println!("   Created RL-based NAS:");
150    println!("   - Agent type: Policy Gradient");
151    println!("   - Exploration rate: 0.3");
152    println!("   - Learning rate: 0.01");
153
154    println!("\n   Running RL search for 100 episodes...");
155    let best_architectures = nas.search(100)?;
156
157    println!("   RL search complete!");
158    println!("   - Architectures found: {}", best_architectures.len());
159
160    if let Some(best) = best_architectures.first() {
161        println!("   - Best RL architecture: {best}");
162        if let Some(entanglement) = best.properties.entanglement_capability {
163            println!("   - Entanglement capability: {entanglement:.3}");
164        }
165    }
166
167    Ok(())
168}
169
170/// Bayesian optimization search demonstration
171fn bayesian_search_demo() -> Result<()> {
172    let search_space = create_default_search_space();
173
174    let strategy = SearchStrategy::BayesianOptimization {
175        acquisition_function: AcquisitionFunction::ExpectedImprovement,
176        num_initial_points: 10,
177    };
178
179    let mut nas = QuantumNAS::new(strategy, search_space);
180
181    println!("   Created Bayesian optimization NAS:");
182    println!("   - Acquisition function: Expected Improvement");
183    println!("   - Initial random points: 10");
184
185    // Set up evaluation data
186    let eval_data = generate_quantum_data(60, 4);
187    let eval_labels = Array1::from_shape_fn(60, |i| i % 3);
188    nas.set_evaluation_data(eval_data, eval_labels);
189
190    println!("\n   Running Bayesian optimization for 30 iterations...");
191    let best_architectures = nas.search(30)?;
192
193    println!("   Bayesian optimization complete!");
194    if let Some(best) = best_architectures.first() {
195        println!("   - Best Bayesian architecture: {best}");
196        if let Some(hardware_eff) = best.metrics.hardware_efficiency {
197            println!("   - Hardware efficiency: {hardware_eff:.3}");
198        }
199    }
200
201    Ok(())
202}
203
204/// DARTS demonstration
205fn darts_demo() -> Result<()> {
206    let search_space = create_darts_search_space();
207
208    let strategy = SearchStrategy::DARTS {
209        learning_rate: 0.01,
210        weight_decay: 1e-4,
211    };
212
213    let mut nas = QuantumNAS::new(strategy, search_space);
214
215    println!("   Created DARTS NAS:");
216    println!("   - Learning rate: 0.01");
217    println!("   - Weight decay: 1e-4");
218    println!("   - Differentiable architecture search");
219
220    println!("\n   Running DARTS for 200 epochs...");
221    let best_architectures = nas.search(200)?;
222
223    println!("   DARTS search complete!");
224    if let Some(best) = best_architectures.first() {
225        println!("   - DARTS architecture: {best}");
226        println!("   - Learned through gradient-based optimization");
227
228        if let Some(gradient_var) = best.properties.gradient_variance {
229            println!("   - Gradient variance: {gradient_var:.3}");
230        }
231    }
232
233    Ok(())
234}
235
236/// Multi-objective optimization demonstration
237fn multi_objective_demo() -> Result<()> {
238    let search_space = create_default_search_space();
239
240    let strategy = SearchStrategy::Evolutionary {
241        population_size: 30,
242        mutation_rate: 0.15,
243        crossover_rate: 0.8,
244        elitism_ratio: 0.2,
245    };
246
247    let mut nas = QuantumNAS::new(strategy, search_space);
248
249    println!("   Multi-objective optimization:");
250    println!("   - Optimizing accuracy vs. complexity");
251    println!("   - Finding Pareto-optimal architectures");
252
253    // Run search
254    nas.search(15)?;
255
256    // Analyze Pareto front
257    let pareto_front = nas.get_pareto_front();
258    println!("   Pareto front analysis:");
259    println!("   - Pareto-optimal architectures: {}", pareto_front.len());
260
261    for (i, arch) in pareto_front.iter().take(3).enumerate() {
262        println!(
263            "   Architecture {}: {} params, {:.3} accuracy",
264            i + 1,
265            arch.metrics.parameter_count,
266            arch.metrics.accuracy.unwrap_or(0.0)
267        );
268    }
269
270    Ok(())
271}
Source

pub fn set_evaluation_data(&mut self, data: Array2<f64>, labels: Array1<usize>)

Set evaluation dataset

Examples found in repository?
examples/quantum_nas.rs (line 73)
50fn evolutionary_search_demo() -> Result<()> {
51    // Create search space
52    let search_space = create_default_search_space();
53
54    // Configure evolutionary strategy
55    let strategy = SearchStrategy::Evolutionary {
56        population_size: 20,
57        mutation_rate: 0.2,
58        crossover_rate: 0.7,
59        elitism_ratio: 0.1,
60    };
61
62    let mut nas = QuantumNAS::new(strategy, search_space);
63
64    println!("   Created evolutionary NAS:");
65    println!("   - Population size: 20");
66    println!("   - Mutation rate: 0.2");
67    println!("   - Crossover rate: 0.7");
68    println!("   - Elitism ratio: 0.1");
69
70    // Set evaluation data (synthetic for demo)
71    let eval_data = Array2::from_shape_fn((100, 4), |(i, j)| (i as f64 + j as f64) / 50.0);
72    let eval_labels = Array1::from_shape_fn(100, |i| i % 2);
73    nas.set_evaluation_data(eval_data, eval_labels);
74
75    // Run search
76    println!("\n   Running evolutionary search for 10 generations...");
77    let best_architectures = nas.search(10)?;
78
79    println!("   Search complete!");
80    println!(
81        "   - Best architectures found: {}",
82        best_architectures.len()
83    );
84
85    if let Some(best) = best_architectures.first() {
86        println!("   - Best architecture: {best}");
87        println!("   - Circuit depth: {}", best.metrics.circuit_depth);
88        println!("   - Parameter count: {}", best.metrics.parameter_count);
89
90        if let Some(expressivity) = best.properties.expressivity {
91            println!("   - Expressivity: {expressivity:.3}");
92        }
93    }
94
95    // Show search summary
96    let summary = nas.get_search_summary();
97    println!(
98        "   - Total architectures evaluated: {}",
99        summary.total_architectures_evaluated
100    );
101    println!("   - Pareto front size: {}", summary.pareto_front_size);
102
103    Ok(())
104}
105
106/// Random search baseline demonstration
107fn random_search_demo() -> Result<()> {
108    let search_space = create_default_search_space();
109    let strategy = SearchStrategy::Random { num_samples: 50 };
110
111    let mut nas = QuantumNAS::new(strategy, search_space);
112
113    println!("   Created random search NAS:");
114    println!("   - Number of samples: 50");
115
116    // Generate synthetic evaluation data
117    let eval_data = Array2::from_shape_fn((80, 4), |(i, j)| {
118        0.5f64.mul_add((i as f64).sin(), 0.3 * (j as f64).cos())
119    });
120    let eval_labels = Array1::from_shape_fn(80, |i| usize::from(i % 3 != 0));
121    nas.set_evaluation_data(eval_data, eval_labels);
122
123    println!("\n   Running random search...");
124    let best_architectures = nas.search(50)?;
125
126    println!("   Random search complete!");
127    if let Some(best) = best_architectures.first() {
128        println!("   - Best random architecture: {best}");
129        if let Some(accuracy) = best.metrics.accuracy {
130            println!("   - Accuracy: {accuracy:.3}");
131        }
132    }
133
134    Ok(())
135}
136
137/// Reinforcement learning search demonstration
138fn rl_search_demo() -> Result<()> {
139    let search_space = create_custom_search_space();
140
141    let strategy = SearchStrategy::ReinforcementLearning {
142        agent_type: RLAgentType::PolicyGradient,
143        exploration_rate: 0.3,
144        learning_rate: 0.01,
145    };
146
147    let mut nas = QuantumNAS::new(strategy, search_space);
148
149    println!("   Created RL-based NAS:");
150    println!("   - Agent type: Policy Gradient");
151    println!("   - Exploration rate: 0.3");
152    println!("   - Learning rate: 0.01");
153
154    println!("\n   Running RL search for 100 episodes...");
155    let best_architectures = nas.search(100)?;
156
157    println!("   RL search complete!");
158    println!("   - Architectures found: {}", best_architectures.len());
159
160    if let Some(best) = best_architectures.first() {
161        println!("   - Best RL architecture: {best}");
162        if let Some(entanglement) = best.properties.entanglement_capability {
163            println!("   - Entanglement capability: {entanglement:.3}");
164        }
165    }
166
167    Ok(())
168}
169
170/// Bayesian optimization search demonstration
171fn bayesian_search_demo() -> Result<()> {
172    let search_space = create_default_search_space();
173
174    let strategy = SearchStrategy::BayesianOptimization {
175        acquisition_function: AcquisitionFunction::ExpectedImprovement,
176        num_initial_points: 10,
177    };
178
179    let mut nas = QuantumNAS::new(strategy, search_space);
180
181    println!("   Created Bayesian optimization NAS:");
182    println!("   - Acquisition function: Expected Improvement");
183    println!("   - Initial random points: 10");
184
185    // Set up evaluation data
186    let eval_data = generate_quantum_data(60, 4);
187    let eval_labels = Array1::from_shape_fn(60, |i| i % 3);
188    nas.set_evaluation_data(eval_data, eval_labels);
189
190    println!("\n   Running Bayesian optimization for 30 iterations...");
191    let best_architectures = nas.search(30)?;
192
193    println!("   Bayesian optimization complete!");
194    if let Some(best) = best_architectures.first() {
195        println!("   - Best Bayesian architecture: {best}");
196        if let Some(hardware_eff) = best.metrics.hardware_efficiency {
197            println!("   - Hardware efficiency: {hardware_eff:.3}");
198        }
199    }
200
201    Ok(())
202}
Source

pub fn search( &mut self, max_iterations: usize, ) -> Result<Vec<ArchitectureCandidate>>

Search for optimal architectures

Examples found in repository?
examples/quantum_nas.rs (line 77)
50fn evolutionary_search_demo() -> Result<()> {
51    // Create search space
52    let search_space = create_default_search_space();
53
54    // Configure evolutionary strategy
55    let strategy = SearchStrategy::Evolutionary {
56        population_size: 20,
57        mutation_rate: 0.2,
58        crossover_rate: 0.7,
59        elitism_ratio: 0.1,
60    };
61
62    let mut nas = QuantumNAS::new(strategy, search_space);
63
64    println!("   Created evolutionary NAS:");
65    println!("   - Population size: 20");
66    println!("   - Mutation rate: 0.2");
67    println!("   - Crossover rate: 0.7");
68    println!("   - Elitism ratio: 0.1");
69
70    // Set evaluation data (synthetic for demo)
71    let eval_data = Array2::from_shape_fn((100, 4), |(i, j)| (i as f64 + j as f64) / 50.0);
72    let eval_labels = Array1::from_shape_fn(100, |i| i % 2);
73    nas.set_evaluation_data(eval_data, eval_labels);
74
75    // Run search
76    println!("\n   Running evolutionary search for 10 generations...");
77    let best_architectures = nas.search(10)?;
78
79    println!("   Search complete!");
80    println!(
81        "   - Best architectures found: {}",
82        best_architectures.len()
83    );
84
85    if let Some(best) = best_architectures.first() {
86        println!("   - Best architecture: {best}");
87        println!("   - Circuit depth: {}", best.metrics.circuit_depth);
88        println!("   - Parameter count: {}", best.metrics.parameter_count);
89
90        if let Some(expressivity) = best.properties.expressivity {
91            println!("   - Expressivity: {expressivity:.3}");
92        }
93    }
94
95    // Show search summary
96    let summary = nas.get_search_summary();
97    println!(
98        "   - Total architectures evaluated: {}",
99        summary.total_architectures_evaluated
100    );
101    println!("   - Pareto front size: {}", summary.pareto_front_size);
102
103    Ok(())
104}
105
106/// Random search baseline demonstration
107fn random_search_demo() -> Result<()> {
108    let search_space = create_default_search_space();
109    let strategy = SearchStrategy::Random { num_samples: 50 };
110
111    let mut nas = QuantumNAS::new(strategy, search_space);
112
113    println!("   Created random search NAS:");
114    println!("   - Number of samples: 50");
115
116    // Generate synthetic evaluation data
117    let eval_data = Array2::from_shape_fn((80, 4), |(i, j)| {
118        0.5f64.mul_add((i as f64).sin(), 0.3 * (j as f64).cos())
119    });
120    let eval_labels = Array1::from_shape_fn(80, |i| usize::from(i % 3 != 0));
121    nas.set_evaluation_data(eval_data, eval_labels);
122
123    println!("\n   Running random search...");
124    let best_architectures = nas.search(50)?;
125
126    println!("   Random search complete!");
127    if let Some(best) = best_architectures.first() {
128        println!("   - Best random architecture: {best}");
129        if let Some(accuracy) = best.metrics.accuracy {
130            println!("   - Accuracy: {accuracy:.3}");
131        }
132    }
133
134    Ok(())
135}
136
137/// Reinforcement learning search demonstration
138fn rl_search_demo() -> Result<()> {
139    let search_space = create_custom_search_space();
140
141    let strategy = SearchStrategy::ReinforcementLearning {
142        agent_type: RLAgentType::PolicyGradient,
143        exploration_rate: 0.3,
144        learning_rate: 0.01,
145    };
146
147    let mut nas = QuantumNAS::new(strategy, search_space);
148
149    println!("   Created RL-based NAS:");
150    println!("   - Agent type: Policy Gradient");
151    println!("   - Exploration rate: 0.3");
152    println!("   - Learning rate: 0.01");
153
154    println!("\n   Running RL search for 100 episodes...");
155    let best_architectures = nas.search(100)?;
156
157    println!("   RL search complete!");
158    println!("   - Architectures found: {}", best_architectures.len());
159
160    if let Some(best) = best_architectures.first() {
161        println!("   - Best RL architecture: {best}");
162        if let Some(entanglement) = best.properties.entanglement_capability {
163            println!("   - Entanglement capability: {entanglement:.3}");
164        }
165    }
166
167    Ok(())
168}
169
170/// Bayesian optimization search demonstration
171fn bayesian_search_demo() -> Result<()> {
172    let search_space = create_default_search_space();
173
174    let strategy = SearchStrategy::BayesianOptimization {
175        acquisition_function: AcquisitionFunction::ExpectedImprovement,
176        num_initial_points: 10,
177    };
178
179    let mut nas = QuantumNAS::new(strategy, search_space);
180
181    println!("   Created Bayesian optimization NAS:");
182    println!("   - Acquisition function: Expected Improvement");
183    println!("   - Initial random points: 10");
184
185    // Set up evaluation data
186    let eval_data = generate_quantum_data(60, 4);
187    let eval_labels = Array1::from_shape_fn(60, |i| i % 3);
188    nas.set_evaluation_data(eval_data, eval_labels);
189
190    println!("\n   Running Bayesian optimization for 30 iterations...");
191    let best_architectures = nas.search(30)?;
192
193    println!("   Bayesian optimization complete!");
194    if let Some(best) = best_architectures.first() {
195        println!("   - Best Bayesian architecture: {best}");
196        if let Some(hardware_eff) = best.metrics.hardware_efficiency {
197            println!("   - Hardware efficiency: {hardware_eff:.3}");
198        }
199    }
200
201    Ok(())
202}
203
204/// DARTS demonstration
205fn darts_demo() -> Result<()> {
206    let search_space = create_darts_search_space();
207
208    let strategy = SearchStrategy::DARTS {
209        learning_rate: 0.01,
210        weight_decay: 1e-4,
211    };
212
213    let mut nas = QuantumNAS::new(strategy, search_space);
214
215    println!("   Created DARTS NAS:");
216    println!("   - Learning rate: 0.01");
217    println!("   - Weight decay: 1e-4");
218    println!("   - Differentiable architecture search");
219
220    println!("\n   Running DARTS for 200 epochs...");
221    let best_architectures = nas.search(200)?;
222
223    println!("   DARTS search complete!");
224    if let Some(best) = best_architectures.first() {
225        println!("   - DARTS architecture: {best}");
226        println!("   - Learned through gradient-based optimization");
227
228        if let Some(gradient_var) = best.properties.gradient_variance {
229            println!("   - Gradient variance: {gradient_var:.3}");
230        }
231    }
232
233    Ok(())
234}
235
236/// Multi-objective optimization demonstration
237fn multi_objective_demo() -> Result<()> {
238    let search_space = create_default_search_space();
239
240    let strategy = SearchStrategy::Evolutionary {
241        population_size: 30,
242        mutation_rate: 0.15,
243        crossover_rate: 0.8,
244        elitism_ratio: 0.2,
245    };
246
247    let mut nas = QuantumNAS::new(strategy, search_space);
248
249    println!("   Multi-objective optimization:");
250    println!("   - Optimizing accuracy vs. complexity");
251    println!("   - Finding Pareto-optimal architectures");
252
253    // Run search
254    nas.search(15)?;
255
256    // Analyze Pareto front
257    let pareto_front = nas.get_pareto_front();
258    println!("   Pareto front analysis:");
259    println!("   - Pareto-optimal architectures: {}", pareto_front.len());
260
261    for (i, arch) in pareto_front.iter().take(3).enumerate() {
262        println!(
263            "   Architecture {}: {} params, {:.3} accuracy",
264            i + 1,
265            arch.metrics.parameter_count,
266            arch.metrics.accuracy.unwrap_or(0.0)
267        );
268    }
269
270    Ok(())
271}
Source

pub fn get_search_summary(&self) -> SearchSummary

Get search results summary

Examples found in repository?
examples/quantum_nas.rs (line 96)
50fn evolutionary_search_demo() -> Result<()> {
51    // Create search space
52    let search_space = create_default_search_space();
53
54    // Configure evolutionary strategy
55    let strategy = SearchStrategy::Evolutionary {
56        population_size: 20,
57        mutation_rate: 0.2,
58        crossover_rate: 0.7,
59        elitism_ratio: 0.1,
60    };
61
62    let mut nas = QuantumNAS::new(strategy, search_space);
63
64    println!("   Created evolutionary NAS:");
65    println!("   - Population size: 20");
66    println!("   - Mutation rate: 0.2");
67    println!("   - Crossover rate: 0.7");
68    println!("   - Elitism ratio: 0.1");
69
70    // Set evaluation data (synthetic for demo)
71    let eval_data = Array2::from_shape_fn((100, 4), |(i, j)| (i as f64 + j as f64) / 50.0);
72    let eval_labels = Array1::from_shape_fn(100, |i| i % 2);
73    nas.set_evaluation_data(eval_data, eval_labels);
74
75    // Run search
76    println!("\n   Running evolutionary search for 10 generations...");
77    let best_architectures = nas.search(10)?;
78
79    println!("   Search complete!");
80    println!(
81        "   - Best architectures found: {}",
82        best_architectures.len()
83    );
84
85    if let Some(best) = best_architectures.first() {
86        println!("   - Best architecture: {best}");
87        println!("   - Circuit depth: {}", best.metrics.circuit_depth);
88        println!("   - Parameter count: {}", best.metrics.parameter_count);
89
90        if let Some(expressivity) = best.properties.expressivity {
91            println!("   - Expressivity: {expressivity:.3}");
92        }
93    }
94
95    // Show search summary
96    let summary = nas.get_search_summary();
97    println!(
98        "   - Total architectures evaluated: {}",
99        summary.total_architectures_evaluated
100    );
101    println!("   - Pareto front size: {}", summary.pareto_front_size);
102
103    Ok(())
104}
Source

pub fn get_pareto_front(&self) -> &[ArchitectureCandidate]

Get Pareto front

Examples found in repository?
examples/quantum_nas.rs (line 257)
237fn multi_objective_demo() -> Result<()> {
238    let search_space = create_default_search_space();
239
240    let strategy = SearchStrategy::Evolutionary {
241        population_size: 30,
242        mutation_rate: 0.15,
243        crossover_rate: 0.8,
244        elitism_ratio: 0.2,
245    };
246
247    let mut nas = QuantumNAS::new(strategy, search_space);
248
249    println!("   Multi-objective optimization:");
250    println!("   - Optimizing accuracy vs. complexity");
251    println!("   - Finding Pareto-optimal architectures");
252
253    // Run search
254    nas.search(15)?;
255
256    // Analyze Pareto front
257    let pareto_front = nas.get_pareto_front();
258    println!("   Pareto front analysis:");
259    println!("   - Pareto-optimal architectures: {}", pareto_front.len());
260
261    for (i, arch) in pareto_front.iter().take(3).enumerate() {
262        println!(
263            "   Architecture {}: {} params, {:.3} accuracy",
264            i + 1,
265            arch.metrics.parameter_count,
266            arch.metrics.accuracy.unwrap_or(0.0)
267        );
268    }
269
270    Ok(())
271}

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> 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, 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