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

pub fn get_search_summary(&self) -> SearchSummary

Get search results summary

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

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

Get Pareto front

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

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