Skip to content

Rename the if_ok! macro #12037

Closed
Closed
@alexcrichton

Description

@alexcrichton

Removing io_error was bad enough, I didn't want to worry too much about naming this macro at the time. The name if_ok!() isn't fantastic, and we should probably rename it.

  • try!() - short, succinct, but can possibly evoke the notion of try/catch exceptions from other languages
  • ok!() - also short and succinct, but may not always be clear what it's doing.
  • if_ok!() - works well for let statements, not always clear what it's doing though.

Some code that I think should be considered when naming this macro:

fn foo() -> io::IoResult<()> {
    if_ok!(some_function());

    let bar = if_ok!(some_function());

    if if_ok!(some_function()) {
        // ...
    }

    match if_ok!(some_function()) {
        // ...
    }
}

Nominating.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions