pub enum AnyExpr {
Point(Expr<Point>),
Line(Expr<Line>),
Number(Expr<Number>),
Circle(Expr<Circle>),
PointCollection(Expr<PointCollection>),
Derived(Expr<Derived>),
Unknown(Expr<Unknown>),
}
Expand description
A type-erased unrolled expression.
Variants§
Point(Expr<Point>)
Line(Expr<Line>)
Number(Expr<Number>)
Circle(Expr<Circle>)
PointCollection(Expr<PointCollection>)
Derived(Expr<Derived>)
Unknown(Expr<Unknown>)
Implementations§
Source§impl AnyExpr
impl AnyExpr
Sourcepub fn get_span_mut(&mut self) -> &mut Span
pub fn get_span_mut(&mut self) -> &mut Span
Clones the expression and sets its own span. This will be treated as a separate expression now.
Sourcepub fn replace_node(&mut self, with: Option<AnyExprNode>) -> Option<AnyExprNode>
pub fn replace_node(&mut self, with: Option<AnyExprNode>) -> Option<AnyExprNode>
Replace the display node with the given node. Also returns the old node.
pub fn to_scalar(self) -> Option<Expr<Number>>
pub fn as_point(&self) -> Option<&Expr<Point>>
Sourcepub fn convert_to(self, to: Type, context: &CompileContext) -> Self
pub fn convert_to(self, to: Type, context: &CompileContext) -> Self
Sourcepub fn can_convert_to(&self, to: Type) -> bool
pub fn can_convert_to(&self, to: Type) -> bool
Check if this expression is convertible to the given type.
Sourcepub fn can_convert_to_scalar(
&self,
unit: Option<ComplexUnit>,
) -> Option<Option<ComplexUnit>>
pub fn can_convert_to_scalar( &self, unit: Option<ComplexUnit>, ) -> Option<Option<ComplexUnit>>
Check if the expression is convertible to the given type.
Note that unit
of None
is ANY scalar, not UNKNOWN-UNIT scalar here.
Returns None
if conversion isn’t possible and Some
with a unit
this value would be converted to. If unit
is None
and the value
is also an unknown-unit scalar, Some(None)
is returned.
Sourcepub fn can_convert_to_collection(&self, len: usize) -> Option<usize>
pub fn can_convert_to_collection(&self, len: usize) -> Option<usize>
Check if the expression is convertible to a point collection of the given length.
Sourcepub fn can_convert_to_derived(&self, name: &str) -> bool
pub fn can_convert_to_derived(&self, name: &str) -> bool
Check if the expression is convertible to a derived type with the given name.
Sourcepub fn get_variable_span(&self) -> Span
pub fn get_variable_span(&self) -> Span
Sourcepub fn make_variable(self, name: String) -> Self
pub fn make_variable(self, name: String) -> Self
Turn this expression into a variable with the given name.
pub fn as_derived(&self) -> Option<&Expr<Derived>>
pub fn try_into_derived(self) -> Result<Expr<Derived>, Self>
pub fn as_number(&self) -> Option<&Expr<Number>>
Trait Implementations§
Source§impl CloneWithNode for AnyExpr
impl CloneWithNode for AnyExpr
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<AnyExpr> for Circle
impl ConvertFrom<AnyExpr> for Circle
Source§fn convert_from(value: AnyExpr, context: &CompileContext) -> Expr<Self>
fn convert_from(value: AnyExpr, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§fn can_convert_from(value: &AnyExpr) -> bool
fn can_convert_from(value: &AnyExpr) -> bool
Self
can be made.Source§impl ConvertFrom<AnyExpr> for Derived
impl ConvertFrom<AnyExpr> for Derived
Source§fn convert_from(value: AnyExpr, context: &CompileContext) -> Expr<Self>
fn convert_from(value: AnyExpr, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§fn can_convert_from(value: &AnyExpr) -> bool
fn can_convert_from(value: &AnyExpr) -> bool
Self
can be made.Source§impl ConvertFrom<AnyExpr> for Line
impl ConvertFrom<AnyExpr> for Line
Source§fn convert_from(value: AnyExpr, context: &CompileContext) -> Expr<Self>
fn convert_from(value: AnyExpr, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§fn can_convert_from(value: &AnyExpr) -> bool
fn can_convert_from(value: &AnyExpr) -> bool
Self
can be made.Source§impl ConvertFrom<AnyExpr> for Number
impl ConvertFrom<AnyExpr> for Number
Source§fn convert_from(value: AnyExpr, context: &CompileContext) -> Expr<Self>
fn convert_from(value: AnyExpr, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§fn can_convert_from(value: &AnyExpr) -> bool
fn can_convert_from(value: &AnyExpr) -> bool
Self
can be made.Source§impl ConvertFrom<AnyExpr> for Point
impl ConvertFrom<AnyExpr> for Point
Source§fn convert_from(value: AnyExpr, context: &CompileContext) -> Expr<Self>
fn convert_from(value: AnyExpr, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§fn can_convert_from(value: &AnyExpr) -> bool
fn can_convert_from(value: &AnyExpr) -> bool
Self
can be made.Source§impl ConvertFrom<AnyExpr> for PointCollection
impl ConvertFrom<AnyExpr> for PointCollection
Source§fn convert_from(value: AnyExpr, context: &CompileContext) -> Expr<Self>
fn convert_from(value: AnyExpr, context: &CompileContext) -> Expr<Self>
Self
. Read moreSource§fn can_convert_from(value: &AnyExpr) -> bool
fn can_convert_from(value: &AnyExpr) -> bool
Self
can be made.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 DST_NUM: i64, const DST_DENOM: i64, const ANG_NUM: i64, const ANG_DENOM: i64> From<NumberUnit<DST_NUM, DST_DENOM, ANG_NUM, ANG_DENOM>> for AnyExpr
impl<const DST_NUM: i64, const DST_DENOM: i64, const ANG_NUM: i64, const ANG_DENOM: i64> From<NumberUnit<DST_NUM, DST_DENOM, ANG_NUM, ANG_DENOM>> for AnyExpr
Source§fn from(value: NumberUnit<DST_NUM, DST_DENOM, ANG_NUM, ANG_DENOM>) -> Self
fn from(value: NumberUnit<DST_NUM, DST_DENOM, ANG_NUM, ANG_DENOM>) -> Self
Source§impl From<SegmentExpr> for AnyExpr
impl From<SegmentExpr> for AnyExpr
Source§fn from(value: SegmentExpr) -> Self
fn from(value: SegmentExpr) -> Self
Source§impl From<TransformTypeExpr> for AnyExpr
impl From<TransformTypeExpr> for AnyExpr
Source§fn from(value: TransformTypeExpr) -> Self
fn from(value: TransformTypeExpr) -> Self
Auto Trait Implementations§
impl Freeze for AnyExpr
impl !RefUnwindSafe for AnyExpr
impl !Send for AnyExpr
impl !Sync for AnyExpr
impl Unpin for AnyExpr
impl !UnwindSafe for AnyExpr
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