From 820a55857a132a14f5a69960f7cfbeec39b5360f Mon Sep 17 00:00:00 2001 From: Jonas Hietala Date: Fri, 18 Jul 2014 20:39:38 +0200 Subject: Special case for 0 arguments given in format! --- src/libsyntax/ext/format.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index d629bafe2b1..4b245f2c9fd 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -216,10 +216,10 @@ impl<'a, 'b> Context<'a, 'b> { } fn describe_num_args(&self) -> String { - if self.args.len() == 1 { - "there is 1 argument".to_string() - } else { - format!("there are {} arguments", self.args.len()) + match self.args.len() { + 0 => "no arguments given".to_string(), + 1 => "there is 1 argument".to_string(), + x => format!("there are {} arguments", x), } } -- cgit 1.4.1-3-g733a5