Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Is it possible to replace try! with ? #7

Closed
@kornelski

Description

@kornelski

I'm trying to write a rule that replaces try!(x) with x?, but it seems tricky.

This seems to compile (I've had to add a return type):

fn rule1<T,E,X: From<E>>(r: Result<T,E>) -> Result<T,X> {
    replace!(try!(r) => r?);
    Ok(r?)
}

but it doesn't match anything. Without return type I can't use try! nor ? in the pattern, since they expand to return, which rustc typechecks.

Can this replacement be done?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions