diff --git a/fj/src/lib.rs b/fj/src/lib.rs index 44f967bbc..2cf19969c 100644 --- a/fj/src/lib.rs +++ b/fj/src/lib.rs @@ -16,7 +16,8 @@ mod syntax; pub mod prelude { pub use crate::syntax::{ - Group as _, Rotate as _, Sketch as _, Sweep as _, Translate as _, + Difference as _, Group as _, Rotate as _, Sketch as _, Sweep as _, + Translate as _, }; } diff --git a/fj/src/syntax.rs b/fj/src/syntax.rs index 63d08ee89..e79696a08 100644 --- a/fj/src/syntax.rs +++ b/fj/src/syntax.rs @@ -1,3 +1,24 @@ +pub trait Difference { + fn difference(&self, other: &Other) -> crate::Difference2d + where + Other: Clone + Into; +} + +impl Difference for T +where + T: Clone + Into, +{ + fn difference(&self, other: &Other) -> crate::Difference2d + where + Other: Clone + Into, + { + let a = self.clone().into(); + let b = other.clone().into(); + + crate::Difference2d::from_objects(a, b) + } +} + pub trait Group { fn group(&self, other: &Other) -> crate::Group where