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>
impl Expr<Point>
Sourcepub fn x(
self,
span: Span,
display: Properties,
context: &CompileContext,
) -> Expr<Number>
pub fn x( self, span: Span, display: Properties, context: &CompileContext, ) -> Expr<Number>
Get the point’s x coordinate expression.
Sourcepub fn y(
self,
span: Span,
display: Properties,
context: &CompileContext,
) -> Expr<Number>
pub fn y( self, span: Span, display: Properties, context: &CompileContext, ) -> Expr<Number>
Get the point’s y coordinate expression.
Source§impl Expr<Circle>
impl Expr<Circle>
Sourcepub fn center(
self,
span: Span,
display: Properties,
context: &CompileContext,
) -> Expr<Point>
pub fn center( self, span: Span, display: Properties, context: &CompileContext, ) -> Expr<Point>
Get the circle’s center expression.
Sourcepub fn radius(
self,
span: Span,
display: Properties,
context: &CompileContext,
) -> Expr<Number>
pub fn radius( self, span: Span, display: Properties, context: &CompileContext, ) -> Expr<Number>
Get the circle’s radius expression.
Source§impl Expr<Number>
impl Expr<Number>
Sourcepub fn convert_unit(
self,
unit: Option<ComplexUnit>,
context: &CompileContext,
) -> Self
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
Sourcepub fn can_convert_unit(&self, unit: Option<ComplexUnit>) -> bool
pub fn can_convert_unit(&self, unit: Option<ComplexUnit>) -> bool
Checks whether a unit conversion can be performed
Sourcepub fn specify_unit(self, context: &CompileContext) -> Self
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>
impl Expr<PointCollection>
pub fn make_variable(self, name: String) -> Self
Source§impl Expr<PointCollection>
impl Expr<PointCollection>
Sourcepub fn check_len(self, length: usize, context: &CompileContext) -> Self
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.
Sourcepub fn index_without_node(&self, index: usize) -> Expr<Point>
pub fn index_without_node(&self, index: usize) -> Expr<Point>
Get the point at a given index without taking the collection’s node.
Sourcepub fn index_with_node(&mut self, index: usize) -> Expr<Point>
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>
impl Expr<Derived>
Sourcepub fn check_name(self, name: &'static str, context: &CompileContext) -> Self
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
Trait Implementations§
Source§impl<T: Displayed> CloneWithNode for Expr<T>
impl<T: Displayed> CloneWithNode for Expr<T>
Source§fn clone_with_node(&mut self) -> Self
fn clone_with_node(&mut self) -> Self
self
and take its node.Source§fn clone_without_node(&self) -> Self
fn clone_without_node(&self) -> Self
self
without taking its node.Source§impl ConvertFrom<Expr<Circle>> for Circle
impl ConvertFrom<Expr<Circle>> for Circle
Source§fn convert_from(value: Expr<Circle>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Circle>, _context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Circle>> for Derived
impl ConvertFrom<Expr<Circle>> for Derived
Source§fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Circle>> for Line
impl ConvertFrom<Expr<Circle>> for Line
Source§fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Circle>> for Number
impl ConvertFrom<Expr<Circle>> for Number
Source§fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Circle>> for Point
impl ConvertFrom<Expr<Circle>> for Point
Source§fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Circle>> for PointCollection
impl ConvertFrom<Expr<Circle>> for PointCollection
Source§fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Circle>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Derived>> for Circle
impl ConvertFrom<Expr<Derived>> for Circle
Source§fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Derived>> for Derived
impl ConvertFrom<Expr<Derived>> for Derived
Source§fn convert_from(value: Expr<Derived>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Derived>, _context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Derived>> for Line
impl ConvertFrom<Expr<Derived>> for Line
Source§fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Derived>> for Number
impl ConvertFrom<Expr<Derived>> for Number
Source§fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Derived>> for Point
impl ConvertFrom<Expr<Derived>> for Point
Source§fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Derived>> for PointCollection
impl ConvertFrom<Expr<Derived>> for PointCollection
Source§fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Derived>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Line>> for Circle
impl ConvertFrom<Expr<Line>> for Circle
Source§fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Line>> for Derived
impl ConvertFrom<Expr<Line>> for Derived
Source§fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Line>> for Line
impl ConvertFrom<Expr<Line>> for Line
Source§fn convert_from(value: Expr<Line>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Line>, _context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Line>> for Number
impl ConvertFrom<Expr<Line>> for Number
Source§fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Line>> for Point
impl ConvertFrom<Expr<Line>> for Point
Source§fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Line>> for PointCollection
impl ConvertFrom<Expr<Line>> for PointCollection
Source§fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Line>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Number>> for Circle
impl ConvertFrom<Expr<Number>> for Circle
Source§fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Number>> for Derived
impl ConvertFrom<Expr<Number>> for Derived
Source§fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Number>> for Line
impl ConvertFrom<Expr<Number>> for Line
Source§fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Number>> for Number
impl ConvertFrom<Expr<Number>> for Number
Source§fn convert_from(value: Expr<Number>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Number>, _context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Number>> for Point
impl ConvertFrom<Expr<Number>> for Point
Source§fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Number>> for PointCollection
impl ConvertFrom<Expr<Number>> for PointCollection
Source§fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Number>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Point>> for Circle
impl ConvertFrom<Expr<Point>> for Circle
Source§fn convert_from(value: Expr<Point>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Point>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Point>> for Derived
impl ConvertFrom<Expr<Point>> for Derived
Source§fn convert_from(value: Expr<Point>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Point>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Point>> for Line
impl ConvertFrom<Expr<Point>> for Line
Source§fn convert_from(value: Expr<Point>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Point>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Point>> for Number
impl ConvertFrom<Expr<Point>> for Number
Source§fn convert_from(value: Expr<Point>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Point>, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Point>> for Point
impl ConvertFrom<Expr<Point>> for Point
Source§fn convert_from(value: Expr<Point>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Point>, _context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Point>> for PointCollection
impl ConvertFrom<Expr<Point>> for PointCollection
Source§fn convert_from(value: Expr<Point>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Point>, _context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<PointCollection>> for Circle
impl ConvertFrom<Expr<PointCollection>> for Circle
Source§fn convert_from(
value: Expr<PointCollection>,
context: &CompileContext,
) -> Expr<Self>
fn convert_from( value: Expr<PointCollection>, context: &CompileContext, ) -> Expr<Self>
Self
. Read moreSource§fn can_convert_from(_value: &Expr<PointCollection>) -> bool
fn can_convert_from(_value: &Expr<PointCollection>) -> bool
Self
can be made.Source§impl ConvertFrom<Expr<PointCollection>> for Derived
impl ConvertFrom<Expr<PointCollection>> for Derived
Source§fn convert_from(
value: Expr<PointCollection>,
context: &CompileContext,
) -> Expr<Self>
fn convert_from( value: Expr<PointCollection>, context: &CompileContext, ) -> Expr<Self>
Self
. Read moreSource§fn can_convert_from(_value: &Expr<PointCollection>) -> bool
fn can_convert_from(_value: &Expr<PointCollection>) -> bool
Self
can be made.Source§impl ConvertFrom<Expr<PointCollection>> for Line
impl ConvertFrom<Expr<PointCollection>> for Line
Source§fn convert_from(
value: Expr<PointCollection>,
context: &CompileContext,
) -> Expr<Self>
fn convert_from( value: Expr<PointCollection>, context: &CompileContext, ) -> Expr<Self>
Self
. Read moreSource§fn can_convert_from(value: &Expr<PointCollection>) -> bool
fn can_convert_from(value: &Expr<PointCollection>) -> bool
Self
can be made.Source§impl ConvertFrom<Expr<PointCollection>> for Number
impl ConvertFrom<Expr<PointCollection>> for Number
Source§fn convert_from(
value: Expr<PointCollection>,
context: &CompileContext,
) -> Expr<Self>
fn convert_from( value: Expr<PointCollection>, context: &CompileContext, ) -> Expr<Self>
Self
. Read moreSource§fn can_convert_from(value: &Expr<PointCollection>) -> bool
fn can_convert_from(value: &Expr<PointCollection>) -> bool
Self
can be made.Source§impl ConvertFrom<Expr<PointCollection>> for Point
impl ConvertFrom<Expr<PointCollection>> for Point
Source§fn convert_from(
value: Expr<PointCollection>,
context: &CompileContext,
) -> Expr<Self>
fn convert_from( value: Expr<PointCollection>, context: &CompileContext, ) -> Expr<Self>
Self
. Read moreSource§fn can_convert_from(value: &Expr<PointCollection>) -> bool
fn can_convert_from(value: &Expr<PointCollection>) -> bool
Self
can be made.Source§impl ConvertFrom<Expr<PointCollection>> for PointCollection
impl ConvertFrom<Expr<PointCollection>> for PointCollection
Source§fn convert_from(
value: Expr<PointCollection>,
context: &CompileContext,
) -> Expr<Self>
fn convert_from( value: Expr<PointCollection>, context: &CompileContext, ) -> Expr<Self>
Self
. Read moreSource§fn can_convert_from(_value: &Expr<PointCollection>) -> bool
fn can_convert_from(_value: &Expr<PointCollection>) -> bool
Self
can be made.Source§impl ConvertFrom<Expr<Unknown>> for Circle
impl ConvertFrom<Expr<Unknown>> for Circle
Source§fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Unknown>> for Derived
impl ConvertFrom<Expr<Unknown>> for Derived
Source§fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Unknown>> for Line
impl ConvertFrom<Expr<Unknown>> for Line
Source§fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Unknown>> for Number
impl ConvertFrom<Expr<Unknown>> for Number
Source§fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Unknown>> for Point
impl ConvertFrom<Expr<Unknown>> for Point
Source§fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§impl ConvertFrom<Expr<Unknown>> for PointCollection
impl ConvertFrom<Expr<Unknown>> for PointCollection
Source§fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Unknown>, _context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§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>
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§impl From<Expr<PointCollection>> for AnyExpr
impl From<Expr<PointCollection>> for AnyExpr
Source§fn from(value: Expr<PointCollection>) -> Self
fn from(value: Expr<PointCollection>) -> Self
Source§impl<const N: usize> From<Expr<PointCollection>> for Pc<N>
impl<const N: usize> From<Expr<PointCollection>> for Pc<N>
Source§fn from(value: Expr<PointCollection>) -> Self
fn from(value: Expr<PointCollection>) -> Self
Source§impl<T: GetValueType + Displayed> GetValueType for Expr<T>
impl<T: GetValueType + Displayed> GetValueType for Expr<T>
fn get_value_type(&self) -> Type
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Convert for T
impl<T> Convert for T
Source§fn convert<U>(self, context: &CompileContext) -> Expr<U>where
U: ConvertFrom<T>,
fn convert<U>(self, context: &CompileContext) -> Expr<U>where
U: ConvertFrom<T>,
self
into a specific type. Read moreSource§fn can_convert<U>(&self) -> boolwhere
U: ConvertFrom<T>,
fn can_convert<U>(&self) -> boolwhere
U: ConvertFrom<T>,
self
can be converted into a specific type. Read more