Skip to content

Commit 520e286

Browse files
committed
Added better debug print for name
1 parent 0ad994d commit 520e286

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/lib.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
extern crate bitflags;
2828

2929
use std::cmp::min;
30+
use std::fmt;
3031
use std::io::Write;
3132
use std::mem;
3233
use std::result;
@@ -193,7 +194,7 @@ pub enum VarStorageKind {
193194
}
194195

195196
// Represents an identifier which may be a template.
196-
#[derive(Clone, Debug, PartialEq)]
197+
#[derive(Clone, PartialEq)]
197198
pub enum Name<'a> {
198199
Operator(Operator<'a>),
199200
NonTemplate(&'a [u8]),
@@ -203,6 +204,24 @@ pub enum Name<'a> {
203204
AnonymousNamespace,
204205
}
205206

207+
impl<'a> fmt::Debug for Name<'a> {
208+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
209+
match *self {
210+
Name::Operator(ref op) => f.debug_tuple("Operator").field(&op).finish(),
211+
Name::NonTemplate(s) => f
212+
.debug_tuple("NonTemplate")
213+
.field(&String::from_utf8_lossy(s))
214+
.finish(),
215+
Name::Template(ref name, ref params) => {
216+
f.debug_tuple("Template").field(name).field(params).finish()
217+
}
218+
Name::Discriminator(i) => f.debug_tuple("Discriminator").field(&i).finish(),
219+
Name::ParsedName(ref res) => f.debug_tuple("ParsedName").field(res).finish(),
220+
Name::AnonymousNamespace => f.debug_tuple("AnonymousNamespace").finish(),
221+
}
222+
}
223+
}
224+
206225
#[derive(Clone, Debug, PartialEq)]
207226
pub enum Operator<'a> {
208227
Ctor,

0 commit comments

Comments
 (0)