diff --git a/crates/emath/src/pos2.rs b/crates/emath/src/pos2.rs index 485e95c7f..c0a09fdda 100644 --- a/crates/emath/src/pos2.rs +++ b/crates/emath/src/pos2.rs @@ -90,6 +90,22 @@ impl From<&Pos2> for (f32, f32) { } } +// ---------------------------------------------------------------------------- +// Compatibility and convenience conversions to and from Vec2: +impl From for Pos2 { + #[inline(always)] + fn from(v: Vec2) -> Self { + Self { x: v.x, y: v.y } + } +} + +impl From<&Vec2> for Pos2 { + #[inline(always)] + fn from(v: &Vec2) -> Self { + Self { x: v.x, y: v.y } + } +} + // ---------------------------------------------------------------------------- // Mint compatibility and convenience conversions