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: SpanThe 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<Scalar>
pub fn x( self, span: Span, display: Properties, context: &CompileContext, ) -> Expr<Scalar>
Get the point’s x coordinate expression.
sourcepub fn y(
self,
span: Span,
display: Properties,
context: &CompileContext,
) -> Expr<Scalar>
pub fn y( self, span: Span, display: Properties, context: &CompileContext, ) -> Expr<Scalar>
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<Scalar>
pub fn radius( self, span: Span, display: Properties, context: &CompileContext, ) -> Expr<Scalar>
Get the circle’s radius expression.
source§impl Expr<Scalar>
impl Expr<Scalar>
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<Bundle>
impl Expr<Bundle>
sourcepub fn index_without_node(&self, field: &str) -> AnyExpr
pub fn index_without_node(&self, field: &str) -> AnyExpr
Get a field’s value without taking the bundle’s node.
sourcepub fn index_with_node(&mut self, field: &str) -> AnyExpr
pub fn index_with_node(&mut self, field: &str) -> AnyExpr
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 bundle’s name matches the given name.
§Errors
Returns an error if the bundle names don’t match
source§impl<T: CloneWithNode + Displayed> Expr<T>
impl<T: CloneWithNode + Displayed> Expr<T>
sourcepub fn new_spanless(data: T) -> Self
pub fn new_spanless(data: T) -> Self
Creates a new expression without a declared span. WARNING: the expression has no node.
sourcepub fn take_node(&mut self) -> Option<HierarchyNode<T::Node>>
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>
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<Bundle>> for Bundle
impl ConvertFrom<Expr<Bundle>> for Bundle
source§fn convert_from(value: Expr<Bundle>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Bundle>, _context: &CompileContext) -> Expr<Self>
Self. Read moresource§impl ConvertFrom<Expr<Bundle>> for Circle
impl ConvertFrom<Expr<Bundle>> for Circle
source§fn convert_from(value: Expr<Bundle>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Bundle>, context: &CompileContext) -> Expr<Self>
Self. Read moresource§impl ConvertFrom<Expr<Bundle>> for Line
impl ConvertFrom<Expr<Bundle>> for Line
source§fn convert_from(value: Expr<Bundle>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Bundle>, context: &CompileContext) -> Expr<Self>
Self. Read moresource§impl ConvertFrom<Expr<Bundle>> for Point
impl ConvertFrom<Expr<Bundle>> for Point
source§fn convert_from(value: Expr<Bundle>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Bundle>, context: &CompileContext) -> Expr<Self>
Self. Read moresource§impl ConvertFrom<Expr<Bundle>> for PointCollection
impl ConvertFrom<Expr<Bundle>> for PointCollection
source§fn convert_from(value: Expr<Bundle>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Bundle>, context: &CompileContext) -> Expr<Self>
Self. Read moresource§impl ConvertFrom<Expr<Bundle>> for Scalar
impl ConvertFrom<Expr<Bundle>> for Scalar
source§fn convert_from(value: Expr<Bundle>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Bundle>, context: &CompileContext) -> Expr<Self>
Self. Read moresource§impl ConvertFrom<Expr<Circle>> for Bundle
impl ConvertFrom<Expr<Circle>> for Bundle
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 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 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 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<Circle>> for Scalar
impl ConvertFrom<Expr<Circle>> for Scalar
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<Line>> for Bundle
impl ConvertFrom<Expr<Line>> for Bundle
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 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 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 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<Line>> for Scalar
impl ConvertFrom<Expr<Line>> for Scalar
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<Point>> for Bundle
impl ConvertFrom<Expr<Point>> for Bundle
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 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 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 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<Point>> for Scalar
impl ConvertFrom<Expr<Point>> for Scalar
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 Bundle
impl ConvertFrom<Expr<PointCollection>> for Bundle
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 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 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 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<PointCollection>> for Scalar
impl ConvertFrom<Expr<PointCollection>> for Scalar
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<Scalar>> for Bundle
impl ConvertFrom<Expr<Scalar>> for Bundle
source§fn convert_from(value: Expr<Scalar>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Scalar>, context: &CompileContext) -> Expr<Self>
Self. Read moresource§impl ConvertFrom<Expr<Scalar>> for Circle
impl ConvertFrom<Expr<Scalar>> for Circle
source§fn convert_from(value: Expr<Scalar>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Scalar>, context: &CompileContext) -> Expr<Self>
Self. Read moresource§impl ConvertFrom<Expr<Scalar>> for Line
impl ConvertFrom<Expr<Scalar>> for Line
source§fn convert_from(value: Expr<Scalar>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Scalar>, context: &CompileContext) -> Expr<Self>
Self. Read moresource§impl ConvertFrom<Expr<Scalar>> for Point
impl ConvertFrom<Expr<Scalar>> for Point
source§fn convert_from(value: Expr<Scalar>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Scalar>, context: &CompileContext) -> Expr<Self>
Self. Read moresource§impl ConvertFrom<Expr<Scalar>> for PointCollection
impl ConvertFrom<Expr<Scalar>> for PointCollection
source§fn convert_from(value: Expr<Scalar>, context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Scalar>, context: &CompileContext) -> Expr<Self>
Self. Read moresource§impl ConvertFrom<Expr<Scalar>> for Scalar
impl ConvertFrom<Expr<Scalar>> for Scalar
source§fn convert_from(value: Expr<Scalar>, _context: &CompileContext) -> Expr<Self>
fn convert_from(value: Expr<Scalar>, _context: &CompileContext) -> Expr<Self>
Self. Read moresource§impl ConvertFrom<Expr<Unknown>> for Bundle
impl ConvertFrom<Expr<Unknown>> for Bundle
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 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 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 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 ConvertFrom<Expr<Unknown>> for Scalar
impl ConvertFrom<Expr<Unknown>> for Scalar
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 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<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