Struct espr::ir::Instantiables[][src]

pub struct Instantiables {
    pub parts: Vec<PartialComplexEntity>,
}
Expand description

Instantiable subtypes described by a list of partial complex entity, e.g. $[A, B & C]$

This has several operation described in ISO-10303-11 annex B, $+$, $-$, $\And$, and $/$.

  • $A + [B_1, B_2] = [B_1, B_2] + A = [A, B_1, B_2]$
let a = PartialComplexEntity::new(&[1]);
let b1 = PartialComplexEntity::new(&[2]);
let b2 = PartialComplexEntity::new(&[3]);

let ce = Instantiables::new(&[b1.clone(), b2.clone()]);

assert_eq!(a.clone() + ce, Instantiables::new(&[
  a.clone(),
  b1.clone(),
  b2.clone(),
]));
  • $A \And [B_1, B_2] = [B_1, B_2] \And A = [A \And B_1, A \And B_2]$
let a = PartialComplexEntity::new(&[1]);
let b1 = PartialComplexEntity::new(&[2]);
let b2 = PartialComplexEntity::new(&[3]);

let ce = Instantiables::new(&[b1.clone(), b2.clone()]);

assert_eq!(a.clone() & ce, Instantiables::new(&[
  a.clone() & b1.clone(),
  a.clone() & b2.clone(),
]));
  • $[A_1, A_2] + [B_1, B_2] = [A_1, A_2, B_1, B_2]$
let a1 = PartialComplexEntity::new(&[1]);
let a2 = PartialComplexEntity::new(&[2]);
let b1 = PartialComplexEntity::new(&[3]);
let b2 = PartialComplexEntity::new(&[4]);

let ce1 = Instantiables::new(&[a1.clone(), a2.clone()]);
let ce2 = Instantiables::new(&[b1.clone(), b2.clone()]);

assert_eq!(ce1 + ce2, Instantiables::new(&[
  a1.clone(),
  a2.clone(),
  b1.clone(),
  b2.clone(),
]));
  • $[A_1, A_2] \And [B_1, B_2] = [A_1 \And B_1, A_1 \And B_2, A_2 \And B_1, A_2 \And B_2]$
let a1 = PartialComplexEntity::new(&[1]);
let a2 = PartialComplexEntity::new(&[2]);
let b1 = PartialComplexEntity::new(&[3]);
let b2 = PartialComplexEntity::new(&[4]);

let ce1 = Instantiables::new(&[a1.clone(), a2.clone()]);
let ce2 = Instantiables::new(&[b1.clone(), b2.clone()]);

assert_eq!(ce1 & ce2, Instantiables::new(&[
  a1.clone() & b1.clone(),
  a1.clone() & b2.clone(),
  a2.clone() & b1.clone(),
  a2.clone() & b2.clone(),
]));
  • $[A, A \And B, A \And C, A \And B \And D, B \And C, D] / A = [A, A \And B, A \And C, A \And B \And D]$
let a = PartialComplexEntity::new(&[1]);
let b = PartialComplexEntity::new(&[2]);
let c = PartialComplexEntity::new(&[3]);
let d = PartialComplexEntity::new(&[4]);

let ce = Instantiables::new(&[
  a.clone(),
  a.clone() & b.clone(),
  a.clone() & c.clone(),
  a.clone() & b.clone() & d.clone(),
  b.clone() & c.clone(),
  d.clone()
]);

assert_eq!(ce / a.clone(), Instantiables::new(&[
  a.clone(),
  a.clone() & b.clone(),
  a.clone() & c.clone(),
  a.clone() & b.clone() & d.clone(),
]));
  • $ [A, A \And B, A \And C, A \And B \And D, B \And C, D]/[B, D] = [A \And B, A \And B \And D, B \And C, D] $
let a = PartialComplexEntity::new(&[1]);
let b = PartialComplexEntity::new(&[2]);
let c = PartialComplexEntity::new(&[3]);
let d = PartialComplexEntity::new(&[4]);

let ce1 = Instantiables::new(&[
  a.clone(),
  a.clone() & b.clone(),
  a.clone() & c.clone(),
  a.clone() & b.clone() & d.clone(),
  b.clone() & c.clone(),
  d.clone()
]);

let ce2 = Instantiables::new(&[
  b.clone(),
  d.clone()
]);

assert_eq!(ce1 / ce2, Instantiables::new(&[
  a.clone() & b.clone(),
  a.clone() & b.clone() & d.clone(),
  b.clone() & c.clone(),
  d.clone()
]));
  • $[A_1, A_2, B_1, B_2] − [A_2, B_1] = [A_1, B_2]$
let a1 = PartialComplexEntity::new(&[1]);
let a2 = PartialComplexEntity::new(&[2]);
let b1 = PartialComplexEntity::new(&[3]);
let b2 = PartialComplexEntity::new(&[4]);

let ce1 = Instantiables::new(&[
  a1.clone(),
  a2.clone(),
  b1.clone(),
  b2.clone(),
]);

let ce2 = Instantiables::new(&[
  a2.clone(),
  b1.clone()
]);

assert_eq!(ce1 - ce2, Instantiables::new(&[
  a1.clone(),
  b2.clone()
]));

Fields

parts: Vec<PartialComplexEntity>

Sorted and non-duplicated list of partial complex entities

Implementations

Create from single index

ONEOF(A, B, C) -> [A, B, C]

A AND B AND C -> [A & B & C]

A ANDOR B ANDOR C -> [A, B, C, A & B, B & C, A & C, A & B & C]

Restore Path from namespace index

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the & operator.

Performs the & operation. Read more

The resulting type after applying the & operator.

Performs the & operation. Read more

The resulting type after applying the & operator.

Performs the & operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Creates a value from an iterator. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.