diff options
| author | Florian Zeitz <florob@babelmonkeys.de> | 2015-11-03 23:14:37 +0100 |
|---|---|---|
| committer | Florian Zeitz <florob@babelmonkeys.de> | 2015-11-03 23:57:31 +0100 |
| commit | 2aa35f0f6deb1f24c508077e877d1bf95bcc282b (patch) | |
| tree | dabb013ce87a41e16216ae3c59b7d16d743d5f14 /src | |
| parent | 3c60328df8d5ac952d41b5ad1d898d339c82c265 (diff) | |
Honor "enum_trailing_comma" option. Fixes #556
Diffstat (limited to 'src')
| -rw-r--r-- | src/items.rs | 2 | ||||
| -rw-r--r-- | src/lists.rs | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/items.rs b/src/items.rs index e6b401d2ff3..fa15eeca3ac 100644 --- a/src/items.rs +++ b/src/items.rs @@ -693,7 +693,7 @@ impl<'a> FmtVisitor<'a> { let fmt = ListFormatting { tactic: DefinitiveListTactic::Vertical, separator: ",", - trailing_separator: SeparatorTactic::Always, + trailing_separator: SeparatorTactic::from_bool(self.config.enum_trailing_comma), indent: self.block_indent, width: budget, ends_with_newline: true, diff --git a/src/lists.rs b/src/lists.rs index 8182189178a..b05e4d46066 100644 --- a/src/lists.rs +++ b/src/lists.rs @@ -46,6 +46,16 @@ pub enum SeparatorTactic { impl_enum_decodable!(SeparatorTactic, Always, Never, Vertical); +impl SeparatorTactic { + pub fn from_bool(b: bool) -> SeparatorTactic { + if b { + SeparatorTactic::Always + } else { + SeparatorTactic::Never + } + } +} + pub struct ListFormatting<'a> { pub tactic: DefinitiveListTactic, pub separator: &'a str, |
