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

pub fn get_search_summary(&self) -> SearchSummary

Get search results summary

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

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

Get Pareto front

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

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