/// Tries to convert a macro use into a short hand try expression. Returns `None`
/// when the macro is not an instance of `try!` (or parsing the inner expression
/// failed).
Tries to convert a macro use into a short hand try expression. Returns `None`
when the macro is not an instance of `try!` (or parsing the inner expression
failed).
Tries to convert a macro use into a short hand try expression . Returns ` None ` when the macro is not an instance of ` try! ` ( or parsing the inner expression failed ) .
pub(crate) fn convert_try_mac(
    mac: &ast::MacCall,
    context: &RewriteContext<'_>,
) -> Option<ast::Expr> {
    let path = &pprust::path_to_string(&mac.path);
    if path == "try" || path == "r#try" {
        let ts = mac.args.inner_tokens();
        let mut parser = build_parser(context, ts.trees());
        Some(ast::Expr {
            id: ast::NodeId::root(), // dummy value
            kind: ast::ExprKind::Try(parser.parse_expr().ok()?),
            span: mac.span(), // incorrect span, but shouldn't matter too much
            attrs: ast::AttrVec::new(),
            tokens: None,
        })
    } else {
        None
    }
}
pub ( crate ) fn convert_try_mac ( mac : & ast :: MacCall , context : & RewriteContext < ' _ > , ) -> Option < ast :: Expr > { let path = & pprust :: path_to_string ( & mac . path ) ; if path == " " || path == " " { let ts = mac . args . inner_tokens ( ) ; let mut parser = build_parser ( context , ts . trees ( ) ) ; Some ( ast :: Expr { id : ast :: NodeId :: root ( ) , // dummy value kind : ast :: ExprKind :: Try ( parser . parse_expr ( ) . ok ( ) ? ) , span : mac . span ( ) , // incorrect span, but shouldn't matter too much attrs : ast :: AttrVec :: new ( ) , tokens : None , } ) } else { None } }
Tries to convert a macro use into a short hand try expression.
Tries to convert a macro use into a short hand try expression .
mac
&ast::MacCall
context
&RewriteContext<'_>