/// Map an AST binary operator to a HIR binary operator.
///
/// Emits an error if the operator is not a valid binary operator.
Map an AST binary operator to a HIR binary operator.
Emits an error if the operator is not a valid binary operator.
Map an AST binary operator to a HIR binary operator . Emits an error if the operator is not a valid binary operator .
pub fn from<C: DiagEmitter>(ast: Spanned<ast::BinaryOp>, ctx: C) -> Result<Spanned<BinaryOp>> {
        let op = match ast.value {
            ast::BinaryOp::Logical(op) => BinaryOp::Logical(op),
            ast::BinaryOp::Rel(op) => BinaryOp::Rel(op),
            ast::BinaryOp::Match(op) => BinaryOp::Match(op),
            ast::BinaryOp::Shift(op) => BinaryOp::Shift(op),
            ast::BinaryOp::Add => BinaryOp::Add,
            ast::BinaryOp::Sub => BinaryOp::Sub,
            ast::BinaryOp::Concat => BinaryOp::Concat,
            ast::BinaryOp::Mul => BinaryOp::Mul,
            ast::BinaryOp::Div => BinaryOp::Div,
            ast::BinaryOp::Mod => BinaryOp::Mod,
            ast::BinaryOp::Rem => BinaryOp::Rem,
            ast::BinaryOp::Pow => BinaryOp::Pow,
            _ => {
                ctx.emit(DiagBuilder2::error("invalid binary operator").span(ast.span));
                return Err(());
            }
        };
        Ok(Spanned::new(op, ast.span))
    }
pub fn from < C : DiagEmitter > ( ast : Spanned < ast :: BinaryOp > , ctx : C ) -> Result < Spanned < BinaryOp > > { let op = match ast . value { ast :: BinaryOp :: Logical ( op ) => BinaryOp :: Logical ( op ) , ast :: BinaryOp :: Rel ( op ) => BinaryOp :: Rel ( op ) , ast :: BinaryOp :: Match ( op ) => BinaryOp :: Match ( op ) , ast :: BinaryOp :: Shift ( op ) => BinaryOp :: Shift ( op ) , ast :: BinaryOp :: Add => BinaryOp :: Add , ast :: BinaryOp :: Sub => BinaryOp :: Sub , ast :: BinaryOp :: Concat => BinaryOp :: Concat , ast :: BinaryOp :: Mul => BinaryOp :: Mul , ast :: BinaryOp :: Div => BinaryOp :: Div , ast :: BinaryOp :: Mod => BinaryOp :: Mod , ast :: BinaryOp :: Rem => BinaryOp :: Rem , ast :: BinaryOp :: Pow => BinaryOp :: Pow , _ => { ctx . emit ( DiagBuilder2 :: error ( " " ) . span ( ast . span ) ) ; return Err ( ( ) ) ; } } ; Ok ( Spanned :: new ( op , ast . span ) ) }
Map an AST binary operator to a HIR binary operator.
Map an AST binary operator to a HIR binary operator .
ast
Spanned<ast::BinaryOp>
ctx
C