Skip to content

Commit

Permalink
implement from for unit length
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Sep 20, 2024
1 parent bfac6b7 commit 1d6790e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/wasm-lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/wasm-lib/kcl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
26 changes: 26 additions & 0 deletions src/wasm-lib/kcl/src/settings/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,32 @@ impl From<UnitLength> for kittycad::types::UnitLength {
}
}

impl From<kittycad_modeling_cmds::units::UnitLength> 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,

Check warning on line 356 in src/wasm-lib/kcl/src/settings/types/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/wasm-lib/kcl/src/settings/types/mod.rs#L349-L356

Added lines #L349 - L356 were not covered by tests
}
}

Check warning on line 358 in src/wasm-lib/kcl/src/settings/types/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/wasm-lib/kcl/src/settings/types/mod.rs#L358

Added line #L358 was not covered by tests
}

impl From<UnitLength> 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,

Check warning on line 369 in src/wasm-lib/kcl/src/settings/types/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/wasm-lib/kcl/src/settings/types/mod.rs#L362-L369

Added lines #L362 - L369 were not covered by tests
}
}

Check warning on line 371 in src/wasm-lib/kcl/src/settings/types/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/wasm-lib/kcl/src/settings/types/mod.rs#L371

Added line #L371 was not covered by tests
}

/// 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)]
Expand Down

0 comments on commit 1d6790e

Please sign in to comment.