Streamline axis naming
This makes it simpler, from the programmer's perspective, to get the name of an axis as a string slice and to format an axis name into a string. To me, the matching method `Axis::name` seems more direct than the explicit lookup table that it replaces, and I'm hoping that it will be about as easy for the compiler to inline, or even easier. Implementing `Display` enables us to hand an `Axis` to a string formatter without any explicit conversion. It adds extra code in the short run, but I'd expect it to simplify our code in the long run by fitting into the conventions set by the Rust standard library.
This commit is contained in:
parent
a614098b22
commit
6ad3ed1176
2 changed files with 0 additions and 2 deletions
|
@ -517,7 +517,6 @@ impl ProblemPoser for HalfCurvatureRegulator {
|
|||
}
|
||||
|
||||
#[derive(Clone, Copy, Sequence)]
|
||||
|
||||
pub enum Axis { X = 0, Y = 1, Z = 2 }
|
||||
impl Axis {
|
||||
fn name(&self) -> &'static str {
|
||||
|
|
|
@ -6,7 +6,6 @@ use web_sys::{KeyboardEvent, MouseEvent, wasm_bindgen::JsCast};
|
|||
use crate::{
|
||||
AppState,
|
||||
assembly::{
|
||||
Axis,
|
||||
Element,
|
||||
HalfCurvatureRegulator,
|
||||
InversiveDistanceRegulator,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue