Skip to content

Commit

Permalink
Specialize ToString for Symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
camsteffen committed Oct 28, 2022
1 parent 0da281b commit 298253a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,13 @@ impl fmt::Display for Symbol {
}
}

// takes advantage of `str::to_string` specialization
impl ToString for Symbol {
fn to_string(&self) -> String {
self.as_str().to_string()
}
}

impl<S: Encoder> Encodable<S> for Symbol {
default fn encode(&self, s: &mut S) {
s.emit_str(self.as_str());
Expand Down

0 comments on commit 298253a

Please sign in to comment.