Add convenient syntax for fj::Difference2d

This commit is contained in:
Hanno Braun 2022-03-17 13:48:35 +01:00
parent d7bb3a5765
commit 222bb28771
2 changed files with 23 additions and 1 deletions

View File

@ -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 _,
};
}

View File

@ -1,3 +1,24 @@
pub trait Difference {
fn difference<Other>(&self, other: &Other) -> crate::Difference2d
where
Other: Clone + Into<crate::Shape2d>;
}
impl<T> Difference for T
where
T: Clone + Into<crate::Shape2d>,
{
fn difference<Other>(&self, other: &Other) -> crate::Difference2d
where
Other: Clone + Into<crate::Shape2d>,
{
let a = self.clone().into();
let b = other.clone().into();
crate::Difference2d::from_objects(a, b)
}
}
pub trait Group {
fn group<Other>(&self, other: &Other) -> crate::Group
where