Struct Expr

Source
pub struct Expr<T: Displayed> {
    pub data: Rc<T>,
    pub span: Span,
    pub node: Option<HierarchyNode<T::Node>>,
}
Expand description

An unrolled expression with a span and a display node.

Fields§

§data: Rc<T>

The expression kind.

§span: Span

The expression’s span.

§node: Option<HierarchyNode<T::Node>>

The expression’s display node, if any.

Implementations§

Source§

impl Expr<Point>

Source

pub fn boxed(self, span: Span) -> Self

Box this expression with a given span.

Source

pub fn x( self, span: Span, display: Properties, context: &CompileContext, ) -> Expr<Number>

Get the point’s x coordinate expression.

Source

pub fn y( self, span: Span, display: Properties, context: &CompileContext, ) -> Expr<Number>

Get the point’s y coordinate expression.

Source§

impl Expr<Point>

Source

pub fn make_variable(self, name: String) -> Self

Source§

impl Expr<Circle>

Source

pub fn make_variable(self, name: String) -> Self

Source§

impl Expr<Circle>

Source

pub fn boxed(self, span: Span) -> Self

Box this expression with a given span.

Source

pub fn center( self, span: Span, display: Properties, context: &CompileContext, ) -> Expr<Point>

Get the circle’s center expression.

Source

pub fn radius( self, span: Span, display: Properties, context: &CompileContext, ) -> Expr<Number>

Get the circle’s radius expression.

Source§

impl Expr<Line>

Source

pub fn boxed(self, span: Span) -> Self

Box the expression with a span.

Source§

impl Expr<Line>

Source

pub fn make_variable(self, name: String) -> Self

Source§

impl Expr<Number>

Source

pub fn make_variable(self, name: String) -> Self

Source§

impl Expr<Number>

Source

pub fn boxed(self, span: Span) -> Self

Box the expression with a span.

Source

pub fn convert_unit( self, unit: Option<ComplexUnit>, context: &CompileContext, ) -> Self

Try to convert this scalar to the given unit.

§Errors

Returns a conversion error if it is invalid.

Only valid conversions are None to another unit or self to self

Source

pub fn can_convert_unit(&self, unit: Option<ComplexUnit>) -> bool

Checks whether a unit conversion can be performed

Source

pub fn specify_unit(self, context: &CompileContext) -> Self

Make the unit concrete. If the unit is a None, will make it a unitless scalar. Otherwise will do nothing.

§Panics

If bugged

Source§

impl Expr<PointCollection>

Source

pub fn make_variable(self, name: String) -> Self

Source§

impl Expr<PointCollection>

Source

pub fn boxed(self, span: Span) -> Self

Box the expression with the given span.

Source

pub fn check_len(self, length: usize, context: &CompileContext) -> Self

Check if the collection’s length matches the given length. If length is zero, any length is found matching.

§Errors

Returns an error if lengths don’t match up.

Source

pub fn index_without_node(&self, index: usize) -> Expr<Point>

Get the point at a given index without taking the collection’s node.

Source

pub fn index_with_node(&mut self, index: usize) -> Expr<Point>

Get the point at a given index and take the collection’s node.

Source§

impl Expr<Derived>

Source

pub fn make_variable(self, name: String) -> Self

Source§

impl Expr<Derived>

Source

pub fn boxed(self, span: Span) -> Self

Box the expression with the given span.

Source

pub fn check_name(self, name: &'static str, context: &CompileContext) -> Self

Check if the type’s name matches the given name.

§Errors

Returns an error if the type names don’t match

Source§

impl Expr<Unknown>

Source

pub fn make_variable(self, name: String) -> Self

Source§

impl Expr<Unknown>

Source

pub fn boxed(self, span: Span) -> Self

Box the expression with the given span.

Source§

impl<T: GetData + Displayed> Expr<T>

Source

pub fn get_data(&self) -> &T

Get the underlying data without any indirections.

Source§

impl<T: Displayed> Expr<T>

Source

pub fn new_spanless(data: T) -> Self

Creates a new expression without a declared span. WARNING: the expression has no node.

Source

pub fn take_node(&mut self) -> Option<HierarchyNode<T::Node>>

Take the expression’s display node.

Trait Implementations§

Source§

impl<T: Displayed> CloneWithNode for Expr<T>

Source§

fn clone_with_node(&mut self) -> Self

Clone self and take its node.
Source§

fn clone_without_node(&self) -> Self

Clone self without taking its node.
Source§

impl ConvertFrom<Expr<Circle>> for Circle

Source§

fn convert_from(value: Expr<Circle>, _context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Circle>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Circle>> for Derived

Source§

fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Circle>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Circle>> for Line

Source§

fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Circle>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Circle>> for Number

Source§

fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Circle>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Circle>> for Point

Source§

fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Circle>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Circle>> for PointCollection

Source§

fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Circle>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Derived>> for Circle

Source§

fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Derived>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Derived>> for Derived

Source§

fn convert_from(value: Expr<Derived>, _context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Derived>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Derived>> for Line

Source§

fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Derived>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Derived>> for Number

Source§

fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Derived>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Derived>> for Point

Source§

fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Derived>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Derived>> for PointCollection

Source§

fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Derived>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Line>> for Circle

Source§

fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Line>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Line>> for Derived

Source§

fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Line>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Line>> for Line

Source§

fn convert_from(value: Expr<Line>, _context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Line>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Line>> for Number

Source§

fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Line>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Line>> for Point

Source§

fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Line>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Line>> for PointCollection

Source§

fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Line>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Number>> for Circle

Source§

fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Number>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Number>> for Derived

Source§

fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Number>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Number>> for Line

Source§

fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Number>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Number>> for Number

Source§

fn convert_from(value: Expr<Number>, _context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Number>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Number>> for Point

Source§

fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Number>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Number>> for PointCollection

Source§

fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Number>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Point>> for Circle

Source§

fn convert_from(value: Expr<Point>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Point>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Point>> for Derived

Source§

fn convert_from(value: Expr<Point>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Point>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Point>> for Line

Source§

fn convert_from(value: Expr<Point>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Point>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Point>> for Number

Source§

fn convert_from(value: Expr<Point>, context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Point>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Point>> for Point

Source§

fn convert_from(value: Expr<Point>, _context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Point>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Point>> for PointCollection

Source§

fn convert_from(value: Expr<Point>, _context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Point>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<PointCollection>> for Circle

Source§

fn convert_from( value: Expr<PointCollection>, context: &CompileContext, ) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<PointCollection>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<PointCollection>> for Derived

Source§

fn convert_from( value: Expr<PointCollection>, context: &CompileContext, ) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<PointCollection>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<PointCollection>> for Line

Source§

fn convert_from( value: Expr<PointCollection>, context: &CompileContext, ) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(value: &Expr<PointCollection>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<PointCollection>> for Number

Source§

fn convert_from( value: Expr<PointCollection>, context: &CompileContext, ) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(value: &Expr<PointCollection>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<PointCollection>> for Point

Source§

fn convert_from( value: Expr<PointCollection>, context: &CompileContext, ) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(value: &Expr<PointCollection>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<PointCollection>> for PointCollection

Source§

fn convert_from( value: Expr<PointCollection>, context: &CompileContext, ) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<PointCollection>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Unknown>> for Circle

Source§

fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Unknown>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Unknown>> for Derived

Source§

fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Unknown>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Unknown>> for Line

Source§

fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Unknown>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Unknown>> for Number

Source§

fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Unknown>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Unknown>> for Point

Source§

fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Unknown>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl ConvertFrom<Expr<Unknown>> for PointCollection

Source§

fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>

Convert a value to Self. Read more
Source§

fn can_convert_from(_value: &Expr<Unknown>) -> bool

Check if conversion from a value to Self can be made.
Source§

impl<T: Debug + Displayed> Debug for Expr<T>
where T::Node: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Display + Displayed> Display for Expr<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Displayed + Dummy> Dummy for Expr<T>

Source§

fn dummy() -> Self

Create a dummy value pretending to be a valid one.
Source§

fn is_dummy(&self) -> bool

Check if this is a dummy value.
Source§

impl From<Expr<Circle>> for AnyExpr

Source§

fn from(value: Expr<Circle>) -> Self

Converts to this type from the input type.
Source§

impl From<Expr<Derived>> for AnyExpr

Source§

fn from(value: Expr<Derived>) -> Self

Converts to this type from the input type.
Source§

impl From<Expr<Derived>> for SegmentExpr

Source§

fn from(value: Expr<Derived>) -> Self

Converts to this type from the input type.
Source§

impl From<Expr<Derived>> for TransformTypeExpr

Source§

fn from(value: Expr<Derived>) -> Self

Converts to this type from the input type.
Source§

impl From<Expr<Line>> for AnyExpr

Source§

fn from(value: Expr<Line>) -> Self

Converts to this type from the input type.
Source§

impl From<Expr<Number>> for AnyExpr

Source§

fn from(value: Expr<Number>) -> Self

Converts to this type from the input type.
Source§

impl<const DST_NUM: i64, const DST_DENOM: i64, const ANG_NUM: i64, const ANG_DENOM: i64> From<Expr<Number>> for NumberUnit<DST_NUM, DST_DENOM, ANG_NUM, ANG_DENOM>

Source§

fn from(value: Expr<Number>) -> Self

Converts to this type from the input type.
Source§

impl From<Expr<Point>> for AnyExpr

Source§

fn from(value: Expr<Point>) -> Self

Converts to this type from the input type.
Source§

impl From<Expr<PointCollection>> for AnyExpr

Source§

fn from(value: Expr<PointCollection>) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<Expr<PointCollection>> for Pc<N>

Source§

fn from(value: Expr<PointCollection>) -> Self

Converts to this type from the input type.
Source§

impl From<Expr<Unknown>> for AnyExpr

Source§

fn from(value: Expr<Unknown>) -> Self

Converts to this type from the input type.
Source§

impl GeoType for Expr<Circle>

Source§

type Target = Circle

The target Geo-AID type this type can be converted to.
Source§

fn get_type() -> Type

Source§

impl GeoType for Expr<Line>

Source§

type Target = Line

The target Geo-AID type this type can be converted to.
Source§

fn get_type() -> Type

Source§

impl GeoType for Expr<Point>

Source§

type Target = Point

The target Geo-AID type this type can be converted to.
Source§

fn get_type() -> Type

Source§

impl<T: GetValueType + Displayed> GetValueType for Expr<T>

Auto Trait Implementations§

§

impl<T> Freeze for Expr<T>

§

impl<T> !RefUnwindSafe for Expr<T>

§

impl<T> !Send for Expr<T>

§

impl<T> !Sync for Expr<T>

§

impl<T> Unpin for Expr<T>

§

impl<T> !UnwindSafe for Expr<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Convert for T

Source§

fn convert<U>(self, context: &CompileContext) -> Expr<U>
where U: ConvertFrom<T>,

Convert self into a specific type. Read more
Source§

fn can_convert<U>(&self) -> bool
where U: ConvertFrom<T>,

Check if self can be converted into a specific type. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.