From 1d6790edc0d680bdd3660ba692d73134b3996b9b Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Thu, 19 Sep 2024 17:02:15 -0700 Subject: [PATCH] implement from for unit length Signed-off-by: Jess Frazelle --- src/wasm-lib/Cargo.lock | 2 +- src/wasm-lib/kcl/Cargo.toml | 2 +- src/wasm-lib/kcl/src/settings/types/mod.rs | 26 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/wasm-lib/Cargo.lock b/src/wasm-lib/Cargo.lock index e201715052..86ddae8bc2 100644 --- a/src/wasm-lib/Cargo.lock +++ b/src/wasm-lib/Cargo.lock @@ -1400,7 +1400,7 @@ dependencies = [ [[package]] name = "kcl-lib" -version = "0.2.15" +version = "0.2.16" dependencies = [ "anyhow", "approx 0.5.1", diff --git a/src/wasm-lib/kcl/Cargo.toml b/src/wasm-lib/kcl/Cargo.toml index 8ab76a6113..3a9d246db4 100644 --- a/src/wasm-lib/kcl/Cargo.toml +++ b/src/wasm-lib/kcl/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "kcl-lib" description = "KittyCAD Language implementation and tools" -version = "0.2.15" +version = "0.2.16" edition = "2021" license = "MIT" repository = "https://github.com/KittyCAD/modeling-app" diff --git a/src/wasm-lib/kcl/src/settings/types/mod.rs b/src/wasm-lib/kcl/src/settings/types/mod.rs index 91189a57a4..c9bd07eb4e 100644 --- a/src/wasm-lib/kcl/src/settings/types/mod.rs +++ b/src/wasm-lib/kcl/src/settings/types/mod.rs @@ -345,6 +345,32 @@ impl From for kittycad::types::UnitLength { } } +impl From for UnitLength { + fn from(unit: kittycad_modeling_cmds::units::UnitLength) -> Self { + match unit { + kittycad_modeling_cmds::units::UnitLength::Centimeters => UnitLength::Cm, + kittycad_modeling_cmds::units::UnitLength::Feet => UnitLength::Ft, + kittycad_modeling_cmds::units::UnitLength::Inches => UnitLength::In, + kittycad_modeling_cmds::units::UnitLength::Meters => UnitLength::M, + kittycad_modeling_cmds::units::UnitLength::Millimeters => UnitLength::Mm, + kittycad_modeling_cmds::units::UnitLength::Yards => UnitLength::Yd, + } + } +} + +impl From for kittycad_modeling_cmds::units::UnitLength { + fn from(unit: UnitLength) -> Self { + match unit { + UnitLength::Cm => kittycad_modeling_cmds::units::UnitLength::Centimeters, + UnitLength::Ft => kittycad_modeling_cmds::units::UnitLength::Feet, + UnitLength::In => kittycad_modeling_cmds::units::UnitLength::Inches, + UnitLength::M => kittycad_modeling_cmds::units::UnitLength::Meters, + UnitLength::Mm => kittycad_modeling_cmds::units::UnitLength::Millimeters, + UnitLength::Yd => kittycad_modeling_cmds::units::UnitLength::Yards, + } + } +} + /// The types of controls for how to navigate the 3D view. #[derive(Debug, Default, Eq, PartialEq, Clone, Deserialize, Serialize, JsonSchema, ts_rs::TS, Display, FromStr)] #[ts(export)]