Skip to content

Whitespace for negative integers #45

Closed
@johnthagen

Description

@johnthagen

The style guide currently says Use spaces around binary operators, but what about when - is used as a negation "operator"?

Should it be:

fn main() {
    let x = -1;

    let name = match x {
        -1 => "negative one",
        _ => "other",
    };
}

Or:

fn main() {
    let x = - 1;

    let name = match x {
        - 1 => "negative one",
        _ => "other",
    };
}

Sorry if this is trivially obvious, but I couldn't find it explicitly listed. intellij-rust currently formats the match arm to - 1 like in the bottom example, but I didn't want to report a bug unless I could verify that the first example is indeed what the Rust style guide is preferring.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions