Skip to content
This repository was archived by the owner on Oct 9, 2018. It is now read-only.
This repository was archived by the owner on Oct 9, 2018. It is now read-only.

Moving braces to the next line increases readability in some situations #19

@ghost

Description

The guidelines say "Opening braces always go on the same line.", but in some situations (complex match inputs or iterator chains), readability increases when the opening curly bracket is moved to the next line:

Compare these two

for (x, y) in range(0u, 3)
        .flat_map(|e| Repeat::new(e).zip(range(0u, 3)))
        .flat_map(|e| Repeat::new(e).zip(OFFSETS.iter()))
        .map(|((x,y), &(x1,y1))| (x + x1, y + y1)) {
    grid.get_mut(y)
        .and_then(|row| row.get_mut(x))
        .map(|tile| *tile += 1);
}

for (x, y) in range(0u, 3)
    .flat_map(|e| Repeat::new(e).zip(range(0u, 3)))
    .flat_map(|e| Repeat::new(e).zip(OFFSETS.iter()))
    .map(|((x,y), &(x1,y1))| (x + x1, y + y1))
{
    grid.get_mut(y)
        .and_then(|row| row.get_mut(x))
        .map(|tile| *tile += 1);
}

Or

match (rng.gen::<bool>(),
        rng.gen::<bool>(),
        rng.gen::<bool>()) {
    (true,true,true) => { ... },
    ...
}

match (rng.gen::<bool>(),
    rng.gen::<bool>(),
    rng.gen::<bool>())
{
    (true,true,true) => { ... },
    ...
}

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