Add Display impl for FQSN

This commit is contained in:
Greg Shuflin 2021-10-25 12:47:35 -07:00
parent 8ceaa734d2
commit fb0bf29826

View File

@ -83,6 +83,19 @@ impl Fqsn {
}
}
impl fmt::Display for Fqsn {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let delim = "::";
let Fqsn { scopes } = self;
write!(f, "FQSN<{}", scopes[0])?;
for item in scopes[1..].iter() {
write!(f, "{}{}", delim, item)?;
}
write!(f, ">")
}
}
//TODO eventually this should use ItemId's to avoid String-cloning
/// One segment within a scope.
#[derive(Debug, Clone, Eq, PartialEq, Hash, PartialOrd, Ord)]
@ -90,6 +103,13 @@ enum Scope {
Name(Rc<String>),
}
impl fmt::Display for Scope {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Scope::Name(name) = self;
write!(f, "{}", name)
}
}
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub enum SymbolError {