Add trailing commas and clean up formatting #108

Merged
glen merged 5 commits from Vectornaut/dyna3:trailing-commas into main 2025-08-04 23:34:35 +00:00
4 changed files with 14 additions and 14 deletions
Showing only changes of commit bfd5d8e35f - Show all commits

View file

@ -717,14 +717,14 @@ impl Assembly {
// save the tangent space // save the tangent space
self.tangent.set_silent(tangent); self.tangent.set_silent(tangent);
} },
Err(message) => { Err(message) => {
// report the realization status. the `Err(message)` we're // report the realization status. the `Err(message)` we're
// setting the status to has a different type than the // setting the status to has a different type than the
// `Err(message)` we received from the match: we're changing the // `Err(message)` we received from the match: we're changing the
// `Ok` type from `Realization` to `()` // `Ok` type from `Realization` to `()`
self.realization_status.set(Err(message)) self.realization_status.set(Err(message))
} },
} }
} }
@ -804,10 +804,10 @@ impl Assembly {
// restore its normalization // restore its normalization
*rep += motion_proj.column(column_index); *rep += motion_proj.column(column_index);
elt.project_to_normalized(rep); elt.project_to_normalized(rep);
} },
None => { None => {
console_log!("No velocity to unpack for fresh element \"{}\"", elt.id()) console_log!("No velocity to unpack for fresh element \"{}\"", elt.id())
} },
}; };
}); });
} }

View file

@ -910,17 +910,17 @@ pub fn Display() -> View {
if depth < best_depth { if depth < best_depth {
clicked = Some((elt, depth)) clicked = Some((elt, depth))
} }
} },
None => clicked = Some((elt, depth)), None => clicked = Some((elt, depth)),
} },
None => () None => (),
}; };
} }
// if we clicked something, select it // if we clicked something, select it
match clicked { match clicked {
Some((elt, _)) => state.select(&elt, event.shift_key()), Some((elt, _)) => state.select(&elt, event.shift_key()),
None => state.selection.update(|sel| sel.clear()) None => state.selection.update(|sel| sel.clear()),
}; };
}, },
) )

View file

@ -67,8 +67,8 @@ fn RegulatorInput(regulator: Rc<dyn Regulator>) -> View {
Ok(set_pt) => { Ok(set_pt) => {
set_point.set(set_pt); set_point.set(set_pt);
true true
} },
Err(_) => false Err(_) => false,
} }
) )
}, },
@ -162,19 +162,19 @@ fn ElementOutlineItem(element: Rc<dyn Element>) -> View {
"Enter" => { "Enter" => {
state.select(&element_for_handler, event.shift_key()); state.select(&element_for_handler, event.shift_key());
event.prevent_default(); event.prevent_default();
} },
"ArrowRight" if regulated.get() => { "ArrowRight" if regulated.get() => {
let _ = details_node let _ = details_node
.get() .get()
.unchecked_into::<web_sys::Element>() .unchecked_into::<web_sys::Element>()
.set_attribute("open", ""); .set_attribute("open", "");
} },
"ArrowLeft" => { "ArrowLeft" => {
let _ = details_node let _ = details_node
.get() .get()
.unchecked_into::<web_sys::Element>() .unchecked_into::<web_sys::Element>()
.remove_attribute("open"); .remove_attribute("open");
} },
_ => (), _ => (),
glen marked this conversation as resolved

this new comma looks particularly nutty when all of the other commas are being removed. Can we just leave it out, especially given that a null default return will presumably be forever the final branch here? Indeed, isn't the case that there could never be subsequent code here that would have any runtime effect, because the _ branch would always fire, cutting off any chance that subsequent branches would? This latter consideration obviates the need for the comma to avoid the "spurious git diff" phenomenon, since no useful code could ever be added subsequent to this branch. So please leave out this comma, thanks.

this new comma looks particularly nutty when all of the other commas are being removed. Can we just leave it out, especially given that a null default return will presumably be forever the final branch here? Indeed, isn't the case that there could never be subsequent code here that would have any runtime effect, because the `_` branch would always fire, cutting off any chance that subsequent branches would? This latter consideration obviates the need for the comma to avoid the "spurious git diff" phenomenon, since no useful code could ever be added subsequent to this branch. So please leave out this comma, thanks.

Now that we've switched to using commas after match arms wrapped in blocks, should I still remove the commas after catch-all match arms? That would make them the only match arms without commas, which makes them look weird to me.

Now that we've [switched](https://code.studioinfinity.org/StudioInfinity/dyna3/pulls/108#issuecomment-3152) to using commas after match arms wrapped in blocks, should I still remove the commas after catch-all match arms? That would make them the only match arms without commas, which makes them look weird to me.

Yes, agreed, if we are always using commas, they should be here too. Resolving.

Yes, agreed, if we are always using commas, they should be here too. Resolving.
} }
} }

View file

@ -474,7 +474,7 @@ pub fn realize_gram(
None => return Realization { None => return Realization {
result: Err("Cholesky decomposition failed".to_string()), result: Err("Cholesky decomposition failed".to_string()),
history, history,
} },
}; };
let base_step_stacked = hess_cholesky.solve(&neg_grad_stacked); let base_step_stacked = hess_cholesky.solve(&neg_grad_stacked);
let base_step = base_step_stacked.reshape_generic(Dyn(element_dim), Dyn(assembly_dim)); let base_step = base_step_stacked.reshape_generic(Dyn(element_dim), Dyn(assembly_dim));