pub struct NamedExpression { /* private fields */ }Expand description
An expression bundled with a function name for use in constraint streams.
NamedExpression automatically generates unique function names for expressions,
making it easy to use expressions in constraint stream components.
The generated function name follows the pattern expr_{counter} or uses a
provided custom name.
Implementations§
Source§impl NamedExpression
impl NamedExpression
Sourcepub fn new(expression: Expression) -> Self
pub fn new(expression: Expression) -> Self
Creates a new named expression with an auto-generated unique name.
§Example
use solverforge_core::wasm::Expr;
use solverforge_core::constraints::NamedExpression;
let expr = NamedExpression::new(Expr::is_not_null(Expr::param(0)));
assert!(expr.name().starts_with("expr_"));Sourcepub fn with_name(name: impl Into<String>, expression: Expression) -> Self
pub fn with_name(name: impl Into<String>, expression: Expression) -> Self
Creates a named expression with a specific name.
Use this when you want to give your expression a meaningful name for debugging or readability.
§Example
use solverforge_core::wasm::{Expr, FieldAccessExt};
use solverforge_core::constraints::NamedExpression;
let has_room = NamedExpression::with_name(
"lesson_has_room",
Expr::is_not_null(Expr::param(0).get("Lesson", "room"))
);
assert_eq!(has_room.name(), "lesson_has_room");Sourcepub fn expression(&self) -> &Expression
pub fn expression(&self) -> &Expression
Returns the expression.
Sourcepub fn into_expression(self) -> Expression
pub fn into_expression(self) -> Expression
Consumes self and returns the expression.
Sourcepub fn into_parts(self) -> (String, Expression)
pub fn into_parts(self) -> (String, Expression)
Returns a tuple of (name, expression) for registration with WasmModuleBuilder.
Trait Implementations§
Source§impl Clone for NamedExpression
impl Clone for NamedExpression
Source§fn clone(&self) -> NamedExpression
fn clone(&self) -> NamedExpression
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NamedExpression
impl Debug for NamedExpression
Source§impl From<&NamedExpression> for WasmFunction
impl From<&NamedExpression> for WasmFunction
Source§fn from(named: &NamedExpression) -> WasmFunction
fn from(named: &NamedExpression) -> WasmFunction
Converts to this type from the input type.
Source§impl From<NamedExpression> for WasmFunction
impl From<NamedExpression> for WasmFunction
Source§fn from(named: NamedExpression) -> WasmFunction
fn from(named: NamedExpression) -> WasmFunction
Converts to this type from the input type.
Source§impl PartialEq for NamedExpression
impl PartialEq for NamedExpression
impl StructuralPartialEq for NamedExpression
Auto Trait Implementations§
impl Freeze for NamedExpression
impl RefUnwindSafe for NamedExpression
impl Send for NamedExpression
impl Sync for NamedExpression
impl Unpin for NamedExpression
impl UnwindSafe for NamedExpression
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
Mutably borrows from an owned value. Read more