mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-21 17:52:12 +03:00
Specialize ToString for Symbol
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user