Skip to content

Commit

Permalink
Rollup merge of #103656 - camsteffen:symbol-to-string, r=compiler-errors
Browse files Browse the repository at this point in the history
Specialize ToString for Symbol
  • Loading branch information
matthiaskrgr authored Oct 29, 2022
2 parents 790a716 + 298253a commit f41b1bf
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 f41b1bf

Please sign in to comment.