forked from StudioInfinity/dyna3
Refactor: rename loaders and adopt 'Self' type convention (#111)
Resolves #109. Resolves #110. Co-authored-by: Aaron Fenyes <aaron.fenyes@fareycircles.ooo> Reviewed-on: StudioInfinity/dyna3#111 Co-authored-by: Vectornaut <vectornaut@nobody@nowhere.net> Co-committed-by: Vectornaut <vectornaut@nobody@nowhere.net>
This commit is contained in:
parent
ef1a579ac0
commit
a4565281d5
7 changed files with 64 additions and 64 deletions
|
@ -175,8 +175,8 @@ impl Sphere {
|
||||||
label: String,
|
label: String,
|
||||||
color: ElementColor,
|
color: ElementColor,
|
||||||
representation: DVector<f64>,
|
representation: DVector<f64>,
|
||||||
) -> Sphere {
|
) -> Self {
|
||||||
Sphere {
|
Self {
|
||||||
id,
|
id,
|
||||||
label,
|
label,
|
||||||
color,
|
color,
|
||||||
|
@ -194,8 +194,8 @@ impl Element for Sphere {
|
||||||
"sphere".to_string()
|
"sphere".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default(id: String, id_num: u64) -> Sphere {
|
fn default(id: String, id_num: u64) -> Self {
|
||||||
Sphere::new(
|
Self::new(
|
||||||
id,
|
id,
|
||||||
format!("Sphere {id_num}"),
|
format!("Sphere {id_num}"),
|
||||||
[0.75_f32, 0.75_f32, 0.75_f32],
|
[0.75_f32, 0.75_f32, 0.75_f32],
|
||||||
|
@ -275,8 +275,8 @@ impl Point {
|
||||||
label: String,
|
label: String,
|
||||||
color: ElementColor,
|
color: ElementColor,
|
||||||
representation: DVector<f64>,
|
representation: DVector<f64>,
|
||||||
) -> Point {
|
) -> Self {
|
||||||
Point {
|
Self {
|
||||||
id,
|
id,
|
||||||
label,
|
label,
|
||||||
color,
|
color,
|
||||||
|
@ -294,8 +294,8 @@ impl Element for Point {
|
||||||
"point".to_string()
|
"point".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default(id: String, id_num: u64) -> Point {
|
fn default(id: String, id_num: u64) -> Self {
|
||||||
Point::new(
|
Self::new(
|
||||||
id,
|
id,
|
||||||
format!("Point {id_num}"),
|
format!("Point {id_num}"),
|
||||||
[0.75_f32, 0.75_f32, 0.75_f32],
|
[0.75_f32, 0.75_f32, 0.75_f32],
|
||||||
|
@ -348,7 +348,7 @@ impl ProblemPoser for Point {
|
||||||
format!("Point \"{}\" should be indexed before writing problem data", self.id).as_str()
|
format!("Point \"{}\" should be indexed before writing problem data", self.id).as_str()
|
||||||
);
|
);
|
||||||
problem.gram.push_sym(index, index, 0.0);
|
problem.gram.push_sym(index, index, 0.0);
|
||||||
problem.frozen.push(Point::WEIGHT_COMPONENT, index, 0.5);
|
problem.frozen.push(Self::WEIGHT_COMPONENT, index, 0.5);
|
||||||
problem.guess.set_column(index, &self.representation.get_clone_untracked());
|
problem.guess.set_column(index, &self.representation.get_clone_untracked());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,7 +393,7 @@ pub struct InversiveDistanceRegulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InversiveDistanceRegulator {
|
impl InversiveDistanceRegulator {
|
||||||
pub fn new(subjects: [Rc<dyn Element>; 2]) -> InversiveDistanceRegulator {
|
pub fn new(subjects: [Rc<dyn Element>; 2]) -> Self {
|
||||||
let representations = subjects.each_ref().map(|subj| subj.representation());
|
let representations = subjects.each_ref().map(|subj| subj.representation());
|
||||||
let measurement = create_memo(move || {
|
let measurement = create_memo(move || {
|
||||||
representations[0].with(|rep_0|
|
representations[0].with(|rep_0|
|
||||||
|
@ -406,7 +406,7 @@ impl InversiveDistanceRegulator {
|
||||||
let set_point = create_signal(SpecifiedValue::from_empty_spec());
|
let set_point = create_signal(SpecifiedValue::from_empty_spec());
|
||||||
let serial = Self::next_serial();
|
let serial = Self::next_serial();
|
||||||
|
|
||||||
InversiveDistanceRegulator { subjects, measurement, set_point, serial }
|
Self { subjects, measurement, set_point, serial }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ pub struct HalfCurvatureRegulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HalfCurvatureRegulator {
|
impl HalfCurvatureRegulator {
|
||||||
pub fn new(subject: Rc<dyn Element>) -> HalfCurvatureRegulator {
|
pub fn new(subject: Rc<dyn Element>) -> Self {
|
||||||
let measurement = subject.representation().map(
|
let measurement = subject.representation().map(
|
||||||
|rep| rep[Sphere::CURVATURE_COMPONENT]
|
|rep| rep[Sphere::CURVATURE_COMPONENT]
|
||||||
);
|
);
|
||||||
|
@ -461,7 +461,7 @@ impl HalfCurvatureRegulator {
|
||||||
let set_point = create_signal(SpecifiedValue::from_empty_spec());
|
let set_point = create_signal(SpecifiedValue::from_empty_spec());
|
||||||
let serial = Self::next_serial();
|
let serial = Self::next_serial();
|
||||||
|
|
||||||
HalfCurvatureRegulator { subject, measurement, set_point, serial }
|
Self { subject, measurement, set_point, serial }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ struct DiagnosticsState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DiagnosticsState {
|
impl DiagnosticsState {
|
||||||
fn new(initial_tab: String) -> DiagnosticsState {
|
fn new(initial_tab: String) -> Self {
|
||||||
DiagnosticsState { active_tab: create_signal(initial_tab) }
|
Self { active_tab: create_signal(initial_tab) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ struct SceneSpheres {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SceneSpheres {
|
impl SceneSpheres {
|
||||||
fn new() -> SceneSpheres {
|
fn new() -> Self {
|
||||||
SceneSpheres {
|
Self {
|
||||||
representations: Vec::new(),
|
representations: Vec::new(),
|
||||||
colors_with_opacity: Vec::new(),
|
colors_with_opacity: Vec::new(),
|
||||||
highlights: Vec::new(),
|
highlights: Vec::new(),
|
||||||
|
@ -71,8 +71,8 @@ struct ScenePoints {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ScenePoints {
|
impl ScenePoints {
|
||||||
fn new() -> ScenePoints {
|
fn new() -> Self {
|
||||||
ScenePoints {
|
Self {
|
||||||
representations: Vec::new(),
|
representations: Vec::new(),
|
||||||
colors_with_opacity: Vec::new(),
|
colors_with_opacity: Vec::new(),
|
||||||
highlights: Vec::new(),
|
highlights: Vec::new(),
|
||||||
|
@ -97,8 +97,8 @@ pub struct Scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Scene {
|
impl Scene {
|
||||||
fn new() -> Scene {
|
fn new() -> Self {
|
||||||
Scene {
|
Self {
|
||||||
spheres: SceneSpheres::new(),
|
spheres: SceneSpheres::new(),
|
||||||
points: ScenePoints::new(),
|
points: ScenePoints::new(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::{
|
||||||
// done more work on saving and loading assemblies, we should come back to this
|
// done more work on saving and loading assemblies, we should come back to this
|
||||||
// code to see if it can be simplified
|
// code to see if it can be simplified
|
||||||
|
|
||||||
fn load_gen_assemb(assembly: &Assembly) {
|
fn load_general(assembly: &Assembly) {
|
||||||
let _ = assembly.try_insert_element(
|
let _ = assembly.try_insert_element(
|
||||||
Sphere::new(
|
Sphere::new(
|
||||||
String::from("gemini_a"),
|
String::from("gemini_a"),
|
||||||
|
@ -77,7 +77,7 @@ fn load_gen_assemb(assembly: &Assembly) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_low_curv_assemb(assembly: &Assembly) {
|
fn load_low_curvature(assembly: &Assembly) {
|
||||||
// create the spheres
|
// create the spheres
|
||||||
let a = 0.75_f64.sqrt();
|
let a = 0.75_f64.sqrt();
|
||||||
let _ = assembly.try_insert_element(
|
let _ = assembly.try_insert_element(
|
||||||
|
@ -196,7 +196,7 @@ fn load_low_curv_assemb(assembly: &Assembly) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_pointed_assemb(assembly: &Assembly) {
|
fn load_pointed(assembly: &Assembly) {
|
||||||
let _ = assembly.try_insert_element(
|
let _ = assembly.try_insert_element(
|
||||||
Point::new(
|
Point::new(
|
||||||
format!("point_front"),
|
format!("point_front"),
|
||||||
|
@ -246,7 +246,7 @@ fn load_pointed_assemb(assembly: &Assembly) {
|
||||||
// B-C "
|
// B-C "
|
||||||
// C-C "
|
// C-C "
|
||||||
// A-C -0.25 * φ^2 = -0.6545084971874737
|
// A-C -0.25 * φ^2 = -0.6545084971874737
|
||||||
fn load_tridim_icosahedron_assemb(assembly: &Assembly) {
|
fn load_tridiminished_icosahedron(assembly: &Assembly) {
|
||||||
// create the vertices
|
// create the vertices
|
||||||
const COLOR_A: ElementColor = [1.00_f32, 0.25_f32, 0.25_f32];
|
const COLOR_A: ElementColor = [1.00_f32, 0.25_f32, 0.25_f32];
|
||||||
const COLOR_B: ElementColor = [0.75_f32, 0.75_f32, 0.75_f32];
|
const COLOR_B: ElementColor = [0.75_f32, 0.75_f32, 0.75_f32];
|
||||||
|
@ -409,7 +409,7 @@ fn load_tridim_icosahedron_assemb(assembly: &Assembly) {
|
||||||
|
|
||||||
// to finish describing the dodecahedral circle packing, set the inversive
|
// to finish describing the dodecahedral circle packing, set the inversive
|
||||||
// distance regulators to -1. some of the regulators have already been set
|
// distance regulators to -1. some of the regulators have already been set
|
||||||
fn load_dodeca_packing_assemb(assembly: &Assembly) {
|
fn load_dodecahedral_packing(assembly: &Assembly) {
|
||||||
// add the substrate
|
// add the substrate
|
||||||
let _ = assembly.try_insert_element(
|
let _ = assembly.try_insert_element(
|
||||||
Sphere::new(
|
Sphere::new(
|
||||||
|
@ -550,7 +550,7 @@ fn load_dodeca_packing_assemb(assembly: &Assembly) {
|
||||||
|
|
||||||
// the initial configuration of this test assembly deliberately violates the
|
// the initial configuration of this test assembly deliberately violates the
|
||||||
// constraints, so loading the assembly will trigger a non-trivial realization
|
// constraints, so loading the assembly will trigger a non-trivial realization
|
||||||
fn load_balanced_assemb(assembly: &Assembly) {
|
fn load_balanced(assembly: &Assembly) {
|
||||||
// create the spheres
|
// create the spheres
|
||||||
const R_OUTER: f64 = 10.0;
|
const R_OUTER: f64 = 10.0;
|
||||||
const R_INNER: f64 = 4.0;
|
const R_INNER: f64 = 4.0;
|
||||||
|
@ -611,7 +611,7 @@ fn load_balanced_assemb(assembly: &Assembly) {
|
||||||
|
|
||||||
// the initial configuration of this test assembly deliberately violates the
|
// the initial configuration of this test assembly deliberately violates the
|
||||||
// constraints, so loading the assembly will trigger a non-trivial realization
|
// constraints, so loading the assembly will trigger a non-trivial realization
|
||||||
fn load_off_center_assemb(assembly: &Assembly) {
|
fn load_off_center(assembly: &Assembly) {
|
||||||
// create a point almost at the origin and a sphere centered on the origin
|
// create a point almost at the origin and a sphere centered on the origin
|
||||||
let _ = assembly.try_insert_element(
|
let _ = assembly.try_insert_element(
|
||||||
Point::new(
|
Point::new(
|
||||||
|
@ -648,7 +648,7 @@ fn load_off_center_assemb(assembly: &Assembly) {
|
||||||
// sqrt(1/6) and sqrt(3/2), respectively. to measure those radii, set an
|
// sqrt(1/6) and sqrt(3/2), respectively. to measure those radii, set an
|
||||||
// inversive distance of -1 between the insphere and each face, and then set an
|
// inversive distance of -1 between the insphere and each face, and then set an
|
||||||
// inversive distance of 0 between the circumsphere and each vertex
|
// inversive distance of 0 between the circumsphere and each vertex
|
||||||
fn load_radius_ratio_assemb(assembly: &Assembly) {
|
fn load_radius_ratio(assembly: &Assembly) {
|
||||||
let index_range = 1..=4;
|
let index_range = 1..=4;
|
||||||
|
|
||||||
// create the spheres
|
// create the spheres
|
||||||
|
@ -789,7 +789,7 @@ fn load_radius_ratio_assemb(assembly: &Assembly) {
|
||||||
// conditions are exactly representable as floats, unlike the analogous numbers
|
// conditions are exactly representable as floats, unlike the analogous numbers
|
||||||
// in the scaled-up problem. the inexact representations might break the
|
// in the scaled-up problem. the inexact representations might break the
|
||||||
// symmetry that's getting the engine stuck
|
// symmetry that's getting the engine stuck
|
||||||
fn load_irisawa_hexlet_assemb(assembly: &Assembly) {
|
fn load_irisawa_hexlet(assembly: &Assembly) {
|
||||||
let index_range = 1..=6;
|
let index_range = 1..=6;
|
||||||
let colors = [
|
let colors = [
|
||||||
[1.00_f32, 0.00_f32, 0.25_f32],
|
[1.00_f32, 0.00_f32, 0.25_f32],
|
||||||
|
@ -909,15 +909,15 @@ pub fn TestAssemblyChooser() -> View {
|
||||||
|
|
||||||
// load assembly
|
// load assembly
|
||||||
match name.as_str() {
|
match name.as_str() {
|
||||||
"general" => load_gen_assemb(assembly),
|
"general" => load_general(assembly),
|
||||||
"low-curv" => load_low_curv_assemb(assembly),
|
"low-curvature" => load_low_curvature(assembly),
|
||||||
"pointed" => load_pointed_assemb(assembly),
|
"pointed" => load_pointed(assembly),
|
||||||
"tridim-icosahedron" => load_tridim_icosahedron_assemb(assembly),
|
"tridiminished-icosahedron" => load_tridiminished_icosahedron(assembly),
|
||||||
"dodeca-packing" => load_dodeca_packing_assemb(assembly),
|
"dodecahedral-packing" => load_dodecahedral_packing(assembly),
|
||||||
"balanced" => load_balanced_assemb(assembly),
|
"balanced" => load_balanced(assembly),
|
||||||
"off-center" => load_off_center_assemb(assembly),
|
"off-center" => load_off_center(assembly),
|
||||||
"radius-ratio" => load_radius_ratio_assemb(assembly),
|
"radius-ratio" => load_radius_ratio(assembly),
|
||||||
"irisawa-hexlet" => load_irisawa_hexlet_assemb(assembly),
|
"irisawa-hexlet" => load_irisawa_hexlet(assembly),
|
||||||
_ => (),
|
_ => (),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -927,10 +927,10 @@ pub fn TestAssemblyChooser() -> View {
|
||||||
view! {
|
view! {
|
||||||
select(bind:value = assembly_name) {
|
select(bind:value = assembly_name) {
|
||||||
option(value = "general") { "General" }
|
option(value = "general") { "General" }
|
||||||
option(value = "low-curv") { "Low-curvature" }
|
option(value = "low-curvature") { "Low-curvature" }
|
||||||
option(value = "pointed") { "Pointed" }
|
option(value = "pointed") { "Pointed" }
|
||||||
option(value = "tridim-icosahedron") { "Tridiminished icosahedron" }
|
option(value = "tridiminished-icosahedron") { "Tridiminished icosahedron" }
|
||||||
option(value = "dodeca-packing") { "Dodecahedral packing" }
|
option(value = "dodecahedral-packing") { "Dodecahedral packing" }
|
||||||
option(value = "balanced") { "Balanced" }
|
option(value = "balanced") { "Balanced" }
|
||||||
option(value = "off-center") { "Off-center" }
|
option(value = "off-center") { "Off-center" }
|
||||||
option(value = "radius-ratio") { "Radius ratio" }
|
option(value = "radius-ratio") { "Radius ratio" }
|
||||||
|
|
|
@ -59,12 +59,12 @@ pub struct MatrixEntry {
|
||||||
pub struct PartialMatrix(Vec<MatrixEntry>);
|
pub struct PartialMatrix(Vec<MatrixEntry>);
|
||||||
|
|
||||||
impl PartialMatrix {
|
impl PartialMatrix {
|
||||||
pub fn new() -> PartialMatrix {
|
pub fn new() -> Self {
|
||||||
PartialMatrix(Vec::<MatrixEntry>::new())
|
Self(Vec::<MatrixEntry>::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push(&mut self, row: usize, col: usize, value: f64) {
|
pub fn push(&mut self, row: usize, col: usize, value: f64) {
|
||||||
let PartialMatrix(entries) = self;
|
let Self(entries) = self;
|
||||||
entries.push(MatrixEntry { index: (row, col), value });
|
entries.push(MatrixEntry { index: (row, col), value });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ impl IntoIterator for PartialMatrix {
|
||||||
type IntoIter = std::vec::IntoIter<Self::Item>;
|
type IntoIter = std::vec::IntoIter<Self::Item>;
|
||||||
|
|
||||||
fn into_iter(self) -> Self::IntoIter {
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
let PartialMatrix(entries) = self;
|
let Self(entries) = self;
|
||||||
entries.into_iter()
|
entries.into_iter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,8 +139,8 @@ pub struct ConfigSubspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfigSubspace {
|
impl ConfigSubspace {
|
||||||
pub fn zero(assembly_dim: usize) -> ConfigSubspace {
|
pub fn zero(assembly_dim: usize) -> Self {
|
||||||
ConfigSubspace {
|
Self {
|
||||||
assembly_dim,
|
assembly_dim,
|
||||||
basis_proj: Vec::new(),
|
basis_proj: Vec::new(),
|
||||||
basis_std: Vec::new(),
|
basis_std: Vec::new(),
|
||||||
|
@ -154,7 +154,7 @@ impl ConfigSubspace {
|
||||||
a: DMatrix<f64>,
|
a: DMatrix<f64>,
|
||||||
proj_to_std: DMatrix<f64>,
|
proj_to_std: DMatrix<f64>,
|
||||||
assembly_dim: usize,
|
assembly_dim: usize,
|
||||||
) -> ConfigSubspace {
|
) -> Self {
|
||||||
// find a basis for the kernel. the basis is expressed in the projection
|
// find a basis for the kernel. the basis is expressed in the projection
|
||||||
// coordinates, and it's orthonormal with respect to the projection
|
// coordinates, and it's orthonormal with respect to the projection
|
||||||
// inner product
|
// inner product
|
||||||
|
@ -173,7 +173,7 @@ impl ConfigSubspace {
|
||||||
|
|
||||||
const ELEMENT_DIM: usize = 5;
|
const ELEMENT_DIM: usize = 5;
|
||||||
const UNIFORM_DIM: usize = 4;
|
const UNIFORM_DIM: usize = 4;
|
||||||
ConfigSubspace {
|
Self {
|
||||||
assembly_dim,
|
assembly_dim,
|
||||||
basis_std: basis_std.column_iter().map(
|
basis_std: basis_std.column_iter().map(
|
||||||
|v| Into::<DMatrix<f64>>::into(
|
|v| Into::<DMatrix<f64>>::into(
|
||||||
|
@ -224,8 +224,8 @@ pub struct DescentHistory {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DescentHistory {
|
impl DescentHistory {
|
||||||
pub fn new() -> DescentHistory {
|
pub fn new() -> Self {
|
||||||
DescentHistory {
|
Self {
|
||||||
config: Vec::<DMatrix<f64>>::new(),
|
config: Vec::<DMatrix<f64>>::new(),
|
||||||
scaled_loss: Vec::<f64>::new(),
|
scaled_loss: Vec::<f64>::new(),
|
||||||
neg_grad: Vec::<DMatrix<f64>>::new(),
|
neg_grad: Vec::<DMatrix<f64>>::new(),
|
||||||
|
@ -245,9 +245,9 @@ pub struct ConstraintProblem {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConstraintProblem {
|
impl ConstraintProblem {
|
||||||
pub fn new(element_count: usize) -> ConstraintProblem {
|
pub fn new(element_count: usize) -> Self {
|
||||||
const ELEMENT_DIM: usize = 5;
|
const ELEMENT_DIM: usize = 5;
|
||||||
ConstraintProblem {
|
Self {
|
||||||
gram: PartialMatrix::new(),
|
gram: PartialMatrix::new(),
|
||||||
frozen: PartialMatrix::new(),
|
frozen: PartialMatrix::new(),
|
||||||
guess: DMatrix::<f64>::zeros(ELEMENT_DIM, element_count),
|
guess: DMatrix::<f64>::zeros(ELEMENT_DIM, element_count),
|
||||||
|
@ -255,8 +255,8 @@ impl ConstraintProblem {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "dev")]
|
#[cfg(feature = "dev")]
|
||||||
pub fn from_guess(guess_columns: &[DVector<f64>]) -> ConstraintProblem {
|
pub fn from_guess(guess_columns: &[DVector<f64>]) -> Self {
|
||||||
ConstraintProblem {
|
Self {
|
||||||
gram: PartialMatrix::new(),
|
gram: PartialMatrix::new(),
|
||||||
frozen: PartialMatrix::new(),
|
frozen: PartialMatrix::new(),
|
||||||
guess: DMatrix::from_columns(guess_columns),
|
guess: DMatrix::from_columns(guess_columns),
|
||||||
|
@ -284,10 +284,10 @@ struct SearchState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SearchState {
|
impl SearchState {
|
||||||
fn from_config(gram: &PartialMatrix, config: DMatrix<f64>) -> SearchState {
|
fn from_config(gram: &PartialMatrix, config: DMatrix<f64>) -> Self {
|
||||||
let err_proj = gram.sub_proj(&(config.tr_mul(&*Q) * &config));
|
let err_proj = gram.sub_proj(&(config.tr_mul(&*Q) * &config));
|
||||||
let loss = err_proj.norm_squared();
|
let loss = err_proj.norm_squared();
|
||||||
SearchState { config, err_proj, loss }
|
Self { config, err_proj, loss }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ struct AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppState {
|
impl AppState {
|
||||||
fn new() -> AppState {
|
fn new() -> Self {
|
||||||
AppState {
|
Self {
|
||||||
assembly: Assembly::new(),
|
assembly: Assembly::new(),
|
||||||
selection: create_signal(BTreeSet::default()),
|
selection: create_signal(BTreeSet::default()),
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ pub struct SpecifiedValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SpecifiedValue {
|
impl SpecifiedValue {
|
||||||
pub fn from_empty_spec() -> SpecifiedValue {
|
pub fn from_empty_spec() -> Self {
|
||||||
SpecifiedValue { spec: String::new(), value: None }
|
Self { spec: String::new(), value: None }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_present(&self) -> bool {
|
pub fn is_present(&self) -> bool {
|
||||||
|
@ -34,10 +34,10 @@ impl TryFrom<String> for SpecifiedValue {
|
||||||
|
|
||||||
fn try_from(spec: String) -> Result<Self, Self::Error> {
|
fn try_from(spec: String) -> Result<Self, Self::Error> {
|
||||||
if spec.is_empty() {
|
if spec.is_empty() {
|
||||||
Ok(SpecifiedValue::from_empty_spec())
|
Ok(Self::from_empty_spec())
|
||||||
} else {
|
} else {
|
||||||
spec.parse::<f64>().map(
|
spec.parse::<f64>().map(
|
||||||
|value| SpecifiedValue { spec, value: Some(value) }
|
|value| Self { spec, value: Some(value) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue