[][src]Struct gf::smt::ConstExpr

pub struct ConstExpr { /* fields omitted */ }

Expression that can be evaluated to a constant value.

Example

This example calculates the expression 5 * (4 + 6) using 32-bit integers.

let expr = Expr::new_bit_vec_operator(
    BitVecOperator::Mul,
    vec![
        Expr::new_bit_vec(5u32.into()),
        Expr::new_bit_vec_operator(
            BitVecOperator::Add,
            vec![
                Expr::new_bit_vec(4u32.into()),
                Expr::new_bit_vec(6u32.into()),
            ],
        )?,
    ],
)?;
 
assert_eq!(ConstExpr::new(expr)?.eval(), ExprValue::BitVec(50u32.into()));

Methods

impl ConstExpr[src]

pub fn new(expr: Expr) -> Result<Self, ExprError>[src]

Wrap an expression, checking that it is constant-evaluatable.

pub unsafe fn new_unchecked(expr: Expr) -> Self[src]

Wrap an expression skipping the checks.

pub fn from_value(value: ExprValue) -> Self[src]

Wrap a value.

pub fn into_inner(self) -> Expr[src]

Consume the wrapper and return the underlying expression.

pub fn is_const_expr(expr: &Expr) -> bool[src]

Check if an expression is constant-evaluatable.

pub fn eval(&self) -> ExprValue[src]

Evaluate the expression.

Trait Implementations

impl Clone for ConstExpr[src]

impl Eq for ConstExpr[src]

impl PartialEq<ConstExpr> for ConstExpr[src]

impl Debug for ConstExpr[src]

impl Hash for ConstExpr[src]

impl StructuralPartialEq for ConstExpr[src]

impl StructuralEq for ConstExpr[src]

Auto Trait Implementations

impl Send for ConstExpr

impl Sync for ConstExpr

impl Unpin for ConstExpr

impl UnwindSafe for ConstExpr

impl RefUnwindSafe for ConstExpr

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]