Skip to content

Commit

Permalink
Rollup merge of rust-lang#44223 - eddyb:symbol-from-str, r=jseyfried
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mark-Simulacrum authored Sep 1, 2017
2 parents 3cd4ea3 + 9988e79 commit 9c4bdd3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libsyntax_pos/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ impl Symbol {
}
}

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)
Expand Down

0 comments on commit 9c4bdd3

Please sign in to comment.