I note that while style guide says “Use a space after colons”, almost no existing codes does so in macros. For example,
macro_rules! try(
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
)
That is, $e:expr
, not $e: expr
.
What do you prefer?
Former. No reason, other than everyone else follows that style too.
huon
August 8, 2014, 8:20am
3
I try to use $e: expr
because the expr
is essentially a type for the $e
variable.
I prefer $e:expr
, it makes it clear that expr
is part of the nonterminal pattern token.
Florob
August 9, 2014, 3:33am
5
I personally prefer $e: expr
, it seems more consistent to me. I actually tend to be confused/surprised for a second, whenever I come across the space-less variant.
iopq
August 9, 2014, 3:25pm
6
Oh, everything makes sense now. I couldn’t even parse the syntax for macro_rules! because it just looked like magic macro things.
system
Closed
March 25, 2019, 8:22am
7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.