From c368a38803a735ff915e92609de28732f2e0348d Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Wed, 26 Feb 2025 22:22:58 -0800 Subject: [PATCH 1/2] Make `insert_regulator` private --- app-proto/src/assembly.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-proto/src/assembly.rs b/app-proto/src/assembly.rs index 2ccfc69..739dfc1 100644 --- a/app-proto/src/assembly.rs +++ b/app-proto/src/assembly.rs @@ -272,7 +272,7 @@ impl Assembly { ); } - pub fn insert_regulator(&self, regulator: Regulator) { + fn insert_regulator(&self, regulator: Regulator) { let subjects = regulator.subjects; let key = self.regulators.update(|regs| regs.insert(regulator)); let subject_regulators = self.elements.with( From 7cbd92618b867fcf6d52cb755d454a492768c349 Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Thu, 27 Feb 2025 00:26:54 -0800 Subject: [PATCH 2/2] Improve the comments in the `assembly` module Also, remove trailing comma. --- app-proto/src/assembly.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app-proto/src/assembly.rs b/app-proto/src/assembly.rs index 739dfc1..50b0783 100644 --- a/app-proto/src/assembly.rs +++ b/app-proto/src/assembly.rs @@ -30,8 +30,11 @@ pub struct Element { pub label: String, pub color: ElementColor, pub representation: Signal>, + + // the regulators that affect this element. the ambient assembly is + // responsible for keeping this set up to date pub regulators: Signal>, - + // a serial number, assigned by `Element::new`, that uniquely identifies // each element pub serial: u64, @@ -117,7 +120,7 @@ impl Element { // to construct a `SpecifiedValue` that might be `Present`, use the associated // function `try_from`. this ensures that `spec` is always a valid specification -// of `value` according to the format discussed above the implementation of +// of `value` according to the format discussed at the implementation of // `TryFrom` pub enum SpecifiedValue { Absent, @@ -154,7 +157,8 @@ impl SpecifiedValue { // specification is empty, the `SpecifiedValue` is `Absent`. if the // specification parses to a floating-point value `x`, the `SpecifiedValue` is // `Present`, with a `value` of `x`, and the specification is stored in `spec`. -// these are the only valid specifications; any other produces an error +// these are currently the only valid specifications; any other produces an +// error impl TryFrom for SpecifiedValue { type Error = ParseFloatError; @@ -183,7 +187,7 @@ impl Regulator { self.set_point.set(set_pt); true } - Err(_) => false, + Err(_) => false } } }