Specialize ToString for Symbol

This commit is contained in:
Cameron Steffen
2022-10-27 16:14:48 -05:00
parent 0da281b606
commit 298253af98
+7
View File
@@ -1901,6 +1901,13 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
// 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());