Skip to content

Commit

Permalink
refactor: rename KeepExisting->Preserve variant for match arm pipes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
calebcartwright authored Jul 3, 2020
1 parent 5947aaf commit c3e6be7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ See also: [`match_block_trailing_comma`](#match_block_trailing_comma).
Controls whether to include a leading pipe on match arms

- **Default value**: `Never`
- **Possible values**: `Always`, `Never`, `KeepExisting`
- **Possible values**: `Always`, `Never`, `Preserve`
- **Stable**: Yes

#### `Never` (default):
Expand Down Expand Up @@ -1607,7 +1607,7 @@ fn foo() {
}
```

#### `KeepExisting`:
#### `Preserve`:
```rust
fn foo() {
match foo {
Expand Down
4 changes: 2 additions & 2 deletions src/config/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ pub enum MatchArmLeadingPipe {
Always,
/// Never emit leading pipes on match arms
Never,
/// Maintain any existing leading pipes
KeepExisting,
/// Preserve any existing leading pipes
Preserve,
}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions src/formatting/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ fn rewrite_match_arm(
// 2 = `| `
let (pipe_offset, pipe_str) = match context.config.match_arm_leading_pipes() {
MatchArmLeadingPipe::Never => (0, ""),
MatchArmLeadingPipe::KeepExisting if !has_leading_pipe => (0, ""),
MatchArmLeadingPipe::KeepExisting | MatchArmLeadingPipe::Always => (2, "| "),
MatchArmLeadingPipe::Preserve if !has_leading_pipe => (0, ""),
MatchArmLeadingPipe::Preserve | MatchArmLeadingPipe::Always => (2, "| "),
};

// Patterns
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// rustfmt-match_arm_leading_pipes: KeepExisting
// rustfmt-match_arm_leading_pipes: Preserve

fn foo() {
match foo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// rustfmt-match_arm_leading_pipes: KeepExisting
// rustfmt-match_arm_leading_pipes: Preserve

fn foo() {
match foo {
Expand Down

0 comments on commit c3e6be7

Please sign in to comment.