fn undo_negation(node: SyntaxNode) -> Option<String> {
    match ast::Expr::cast(node)? {
        ast::Expr::BinExpr(bin) => match bin.op_kind()? {
            ast::BinOp::NegatedEqualityTest => {
                let lhs = bin.lhs()?.syntax().text();
                let rhs = bin.rhs()?.syntax().text();
                Some(format!("{} == {}", lhs, rhs))
            }
            _ => None,
        },
        ast::Expr::PrefixExpr(pe) => match pe.op_kind()? {
            ast::PrefixOp::Not => {
                let child = pe.expr()?.syntax().text();
                Some(String::from(child))
            }
            _ => None,
        },
        _ => None,
    }
}
// This function tries to undo unary negation, or inequality
This function tries to undo unary negation, or inequality
This function tries to undo unary negation or inequality
fn undo_negation(node: SyntaxNode) -> Option<String> {
    match ast::Expr::cast(node)? {
        ast::Expr::BinExpr(bin) => match bin.op_kind()? {
            ast::BinOp::NegatedEqualityTest => {
                let lhs = bin.lhs()?.syntax().text();
                let rhs = bin.rhs()?.syntax().text();
                Some(format!("{} == {}", lhs, rhs))
            }
            _ => None,
        },
        ast::Expr::PrefixExpr(pe) => match pe.op_kind()? {
            ast::PrefixOp::Not => {
                let child = pe.expr()?.syntax().text();
                Some(String::from(child))
            }
            _ => None,
        },
        _ => None,
    }
}
fn undo_negation ( node : SyntaxNode ) -> Option < String > { match ast :: Expr :: cast ( node ) ? { ast :: Expr :: BinExpr ( bin ) => match bin . op_kind ( ) ? { ast :: BinOp :: NegatedEqualityTest => { let lhs = bin . lhs ( ) ? . syntax ( ) . text ( ) ; let rhs = bin . rhs ( ) ? . syntax ( ) . text ( ) ; Some ( format ! ( " " lhs rhs ) ) } _ => None , } , ast :: Expr :: PrefixExpr ( pe ) => match pe . op_kind ( ) ? { ast :: PrefixOp :: Not => { let child = pe . expr ( ) ? . syntax ( ) . text ( ) ; Some ( String :: from ( child ) ) } _ => None , } , _ => None , } }
This function tries to undo unary negation, or inequality
This function tries to undo unary negation or inequality
node
SyntaxNode
node
SyntaxNode