fn map_to_expression<F>(&self, f: F) -> Result<Expression>
    where
        F: Fn(&Expression) -> Option<Expression>,
    {
        struct Map<F> {
            f: F,
        }

        impl<F> Map<F>
        where
            F: Fn(&Expression) -> Option<Expression>,
        {
            fn map(&self, expression: &Expression) -> Result<Expression> {
                Ok(if let Some(expression) = (self.f)(expression) {
                    expression
                } else {
                    match *expression {
                        Expression::Scalar(ref scalar) => scalar.clone().into(),
                        Expression::Constant(ref constant) => constant.clone().into(),
                        Expression::Add(ref lhs, ref rhs) => {
                            Expression::add(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Sub(ref lhs, ref rhs) => {
                            Expression::sub(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Mul(ref lhs, ref rhs) => {
                            Expression::mul(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Divu(ref lhs, ref rhs) => {
                            Expression::divu(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Modu(ref lhs, ref rhs) => {
                            Expression::modu(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Divs(ref lhs, ref rhs) => {
                            Expression::divs(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Mods(ref lhs, ref rhs) => {
                            Expression::mods(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::And(ref lhs, ref rhs) => {
                            Expression::and(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Or(ref lhs, ref rhs) => {
                            Expression::or(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Xor(ref lhs, ref rhs) => {
                            Expression::xor(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Shl(ref lhs, ref rhs) => {
                            Expression::shl(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Shr(ref lhs, ref rhs) => {
                            Expression::shr(self.map(lhs)?, self.map(rhs)?)?
                        }
                        #[cfg(feature = "il-expression-ashr")]
                        Expression::AShr(ref lhs, ref rhs) => {
                            Expression::ashr(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Cmpeq(ref lhs, ref rhs) => {
                            Expression::cmpeq(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Cmpneq(ref lhs, ref rhs) => {
                            Expression::cmpneq(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Cmpltu(ref lhs, ref rhs) => {
                            Expression::cmpltu(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Cmplts(ref lhs, ref rhs) => {
                            Expression::cmplts(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Zext(bits, ref src) => Expression::zext(bits, self.map(src)?)?,
                        Expression::Sext(bits, ref src) => Expression::sext(bits, self.map(src)?)?,
                        Expression::Trun(bits, ref src) => Expression::trun(bits, self.map(src)?)?,
                        Expression::Ite(ref cond, ref then, ref else_) => {
                            Expression::ite(self.map(cond)?, self.map(then)?, self.map(else_)?)?
                        }
                    }
                })
            }
        }

        let map = Map { f };

        map.map(self)
    }
/// Takes a closure which modifies an existing `Expression`
///
/// The closure takes an expression, and returns an Option<Expression>. If
/// the option is Some, that value will replace the sub expression in the
/// larger expression. If closure returns None, the original sub
/// expression will be used in the larger expression.
Takes a closure which modifies an existing `Expression`
The closure takes an expression, and returns an Option. If
the option is Some, that value will replace the sub expression in the
larger expression. If closure returns None, the original sub
expression will be used in the larger expression.
Takes a closure which modifies an existing ` Expression ` The closure takes an expression and returns an Option . If the option is Some that value will replace the sub expression in the larger expression . If closure returns None the original sub expression will be used in the larger expression .
fn map_to_expression<F>(&self, f: F) -> Result<Expression>
    where
        F: Fn(&Expression) -> Option<Expression>,
    {
        struct Map<F> {
            f: F,
        }
        impl<F> Map<F>
        where
            F: Fn(&Expression) -> Option<Expression>,
        {
            fn map(&self, expression: &Expression) -> Result<Expression> {
                Ok(if let Some(expression) = (self.f)(expression) {
                    expression
                } else {
                    match *expression {
                        Expression::Scalar(ref scalar) => scalar.clone().into(),
                        Expression::Constant(ref constant) => constant.clone().into(),
                        Expression::Add(ref lhs, ref rhs) => {
                            Expression::add(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Sub(ref lhs, ref rhs) => {
                            Expression::sub(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Mul(ref lhs, ref rhs) => {
                            Expression::mul(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Divu(ref lhs, ref rhs) => {
                            Expression::divu(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Modu(ref lhs, ref rhs) => {
                            Expression::modu(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Divs(ref lhs, ref rhs) => {
                            Expression::divs(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Mods(ref lhs, ref rhs) => {
                            Expression::mods(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::And(ref lhs, ref rhs) => {
                            Expression::and(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Or(ref lhs, ref rhs) => {
                            Expression::or(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Xor(ref lhs, ref rhs) => {
                            Expression::xor(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Shl(ref lhs, ref rhs) => {
                            Expression::shl(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Shr(ref lhs, ref rhs) => {
                            Expression::shr(self.map(lhs)?, self.map(rhs)?)?
                        }
                        #[cfg(feature = "il-expression-ashr")]
                        Expression::AShr(ref lhs, ref rhs) => {
                            Expression::ashr(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Cmpeq(ref lhs, ref rhs) => {
                            Expression::cmpeq(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Cmpneq(ref lhs, ref rhs) => {
                            Expression::cmpneq(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Cmpltu(ref lhs, ref rhs) => {
                            Expression::cmpltu(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Cmplts(ref lhs, ref rhs) => {
                            Expression::cmplts(self.map(lhs)?, self.map(rhs)?)?
                        }
                        Expression::Zext(bits, ref src) => Expression::zext(bits, self.map(src)?)?,
                        Expression::Sext(bits, ref src) => Expression::sext(bits, self.map(src)?)?,
                        Expression::Trun(bits, ref src) => Expression::trun(bits, self.map(src)?)?,
                        Expression::Ite(ref cond, ref then, ref else_) => {
                            Expression::ite(self.map(cond)?, self.map(then)?, self.map(else_)?)?
                        }
                    }
                })
            }
        }
        let map = Map { f };
        map.map(self)
    }
fn map_to_expression < F > ( & self , f : F ) -> Result < Expression > where F : Fn ( & Expression ) -> Option < Expression > , { struct Map < F > { f : F , } impl < F > Map < F > where F : Fn ( & Expression ) -> Option < Expression > , { fn map ( & self , expression : & Expression ) -> Result < Expression > { Ok ( if let Some ( expression ) = ( self . f ) ( expression ) { expression } else { match * expression { Expression :: Scalar ( ref scalar ) => scalar . clone ( ) . into ( ) , Expression :: Constant ( ref constant ) => constant . clone ( ) . into ( ) , Expression :: Add ( ref lhs , ref rhs ) => { Expression :: add ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Sub ( ref lhs , ref rhs ) => { Expression :: sub ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Mul ( ref lhs , ref rhs ) => { Expression :: mul ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Divu ( ref lhs , ref rhs ) => { Expression :: divu ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Modu ( ref lhs , ref rhs ) => { Expression :: modu ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Divs ( ref lhs , ref rhs ) => { Expression :: divs ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Mods ( ref lhs , ref rhs ) => { Expression :: mods ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: And ( ref lhs , ref rhs ) => { Expression :: and ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Or ( ref lhs , ref rhs ) => { Expression :: or ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Xor ( ref lhs , ref rhs ) => { Expression :: xor ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Shl ( ref lhs , ref rhs ) => { Expression :: shl ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Shr ( ref lhs , ref rhs ) => { Expression :: shr ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } # [ cfg ( feature " " ) ] Expression :: AShr ( ref lhs , ref rhs ) => { Expression :: ashr ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Cmpeq ( ref lhs , ref rhs ) => { Expression :: cmpeq ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Cmpneq ( ref lhs , ref rhs ) => { Expression :: cmpneq ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Cmpltu ( ref lhs , ref rhs ) => { Expression :: cmpltu ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Cmplts ( ref lhs , ref rhs ) => { Expression :: cmplts ( self . map ( lhs ) ? , self . map ( rhs ) ? ) ? } Expression :: Zext ( bits , ref src ) => Expression :: zext ( bits , self . map ( src ) ? ) ? , Expression :: Sext ( bits , ref src ) => Expression :: sext ( bits , self . map ( src ) ? ) ? , Expression :: Trun ( bits , ref src ) => Expression :: trun ( bits , self . map ( src ) ? ) ? , Expression :: Ite ( ref cond , ref then , ref else_ ) => { Expression :: ite ( self . map ( cond ) ? , self . map ( then ) ? , self . map ( else_ ) ? ) ? } } } ) } } let map = Map { f } ; map . map ( self ) }
Takes a closure which modifies an existing `Expression`
The closure takes an expression, and returns an Option<Expression>.
Takes a closure which modifies an existing ` Expression ` The closure takes an expression and returns an Option<Expression > .
&self
f
F
&self
f
F