Rollup merge of #103656 - camsteffen:symbol-to-string, r=compiler-errors

Specialize ToString for Symbol
This commit is contained in:
Matthias Krüger 2022-10-29 08:57:36 +02:00 committed by GitHub
commit f41b1bfd0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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());