Skip to content

Allow chaining of comparisons #2083

Open
@Nokel81

Description

@Nokel81

Namely for all comparison operators they should be allowed to be chained. The easy way of disambiguating them is since they are all binary operators just chain them with &&. Lastly, this can help with code clearness since the following can be avoided

let x = fn_long();
let y = fn_other();

if 5 < x && x < 10 && y <= x && 5 < y {
    ...
}

and replaced with:

if 5 < fn_other() <= fn_long() < 10 {
}

where the return values of any non_constant is held in reserve so that the function isn't called multiple times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions