microcad_lang/model/
ops.rs1use microcad_core::{BooleanOp, Integer};
7use microcad_lang_base::SrcRef;
8
9use crate::{
10 eval::EvalResult,
11 model::{Model, Models},
12};
13
14pub type ModelResult = EvalResult<Model>;
15
16impl std::ops::Sub for Model {
17 type Output = ModelResult;
18
19 fn sub(self, rhs: Self) -> Self::Output {
20 Ok(self.boolean_op(BooleanOp::Subtract, rhs))
21 }
22}
23
24impl std::ops::Mul<Model> for Integer {
26 type Output = ModelResult;
27
28 fn mul(self, rhs: Model) -> Self::Output {
29 Ok(Models::from(rhs.multiply(self)).to_multiplicity(SrcRef::none()))
30 }
31}
32
33impl std::ops::BitOr for Model {
35 type Output = ModelResult;
36
37 fn bitor(self, rhs: Self) -> Self::Output {
38 Ok(self.boolean_op(BooleanOp::Union, rhs))
39 }
40}
41
42impl std::ops::BitAnd for Model {
44 type Output = ModelResult;
45
46 fn bitand(self, rhs: Self) -> Self::Output {
47 Ok(self.boolean_op(BooleanOp::Intersect, rhs))
48 }
49}