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:
Vectornaut 2025-08-07 23:24:07 +00:00 committed by Glen Whitney
parent ef1a579ac0
commit a4565281d5
7 changed files with 64 additions and 64 deletions

View file

@ -175,8 +175,8 @@ impl Sphere {
label: String,
color: ElementColor,
representation: DVector<f64>,
) -> Sphere {
Sphere {
) -> Self {
Self {
id,
label,
color,
@ -194,8 +194,8 @@ impl Element for Sphere {
"sphere".to_string()
}
fn default(id: String, id_num: u64) -> Sphere {
Sphere::new(
fn default(id: String, id_num: u64) -> Self {
Self::new(
id,
format!("Sphere {id_num}"),
[0.75_f32, 0.75_f32, 0.75_f32],
@ -275,8 +275,8 @@ impl Point {
label: String,
color: ElementColor,
representation: DVector<f64>,
) -> Point {
Point {
) -> Self {
Self {
id,
label,
color,
@ -294,8 +294,8 @@ impl Element for Point {
"point".to_string()
}
fn default(id: String, id_num: u64) -> Point {
Point::new(
fn default(id: String, id_num: u64) -> Self {
Self::new(
id,
format!("Point {id_num}"),
[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()
);
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());
}
}
@ -393,7 +393,7 @@ pub struct 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 measurement = create_memo(move || {
representations[0].with(|rep_0|
@ -406,7 +406,7 @@ impl InversiveDistanceRegulator {
let set_point = create_signal(SpecifiedValue::from_empty_spec());
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 {
pub fn new(subject: Rc<dyn Element>) -> HalfCurvatureRegulator {
pub fn new(subject: Rc<dyn Element>) -> Self {
let measurement = subject.representation().map(
|rep| rep[Sphere::CURVATURE_COMPONENT]
);
@ -461,7 +461,7 @@ impl HalfCurvatureRegulator {
let set_point = create_signal(SpecifiedValue::from_empty_spec());
let serial = Self::next_serial();
HalfCurvatureRegulator { subject, measurement, set_point, serial }
Self { subject, measurement, set_point, serial }
}
}