Skip to content

Commit

Permalink
Rollup merge of rust-lang#103656 - camsteffen:symbol-to-string, r=com…
Browse files Browse the repository at this point in the history
…piler-errors

Specialize ToString for Symbol
  • Loading branch information
matthiaskrgr committed Oct 29, 2022
2 parents 4d988ce + 298253a commit 50a6af2
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 50a6af2

Please sign in to comment.