diff options
| author | Corey Richardson <corey@octayn.net> | 2014-07-10 19:53:09 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-07-12 20:31:55 -0700 |
| commit | 2dfbe7f9893ef8ff7efc86345941216e564323e7 (patch) | |
| tree | c0d62b20b7e94da1d60203fd9547cbf964a88e6a /src/libsyntax | |
| parent | ca0b65402b107a8d357225945876783fa28122c6 (diff) | |
| download | rust-2dfbe7f9893ef8ff7efc86345941216e564323e7.tar.gz rust-2dfbe7f9893ef8ff7efc86345941216e564323e7.zip | |
Use a nicer Show impl for Name
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 778f77ac7a8..8ba01914648 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -58,7 +58,14 @@ impl Ident { impl Show for Ident { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "\"{}\"#{}", token::get_ident(*self).get(), self.ctxt) + write!(f, "{}#{}", self.name, self.ctxt) + } +} + +impl Show for Name { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let Name(nm) = *self; + write!(f, "\"{}\"({})", token::get_name(*self).get(), nm) } } @@ -106,7 +113,7 @@ pub static ILLEGAL_CTXT : SyntaxContext = 1; /// A name is a part of an identifier, representing a string or gensym. It's /// the result of interning. -#[deriving(Eq, Ord, PartialEq, PartialOrd, Hash, Encodable, Decodable, Clone, Show)] +#[deriving(Eq, Ord, PartialEq, PartialOrd, Hash, Encodable, Decodable, Clone)] pub struct Name(pub u32); impl Name { |
