Rollup merge of #44223 - eddyb:symbol-from-str, r=jseyfried
Implement From<&str> for Symbol. This lets us have `fn foo<S: Into<Symbol>>` bounds and accept both `&str` and existing `Symbol`s. r? @jseyfried
This commit is contained in:
commit
9c4bdd3b87
@ -115,6 +115,12 @@ pub fn as_u32(self) -> u32 {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for Symbol {
|
||||
fn from(string: &'a str) -> Symbol {
|
||||
Symbol::intern(string)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for Symbol {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}({})", self, self.0)
|
||||
|
Loading…
Reference in New Issue
Block a user