Skip to content

Commit

Permalink
add new method for Symbol.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shylock-Hg committed Jan 29, 2025
1 parent 68c4168 commit 747051f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tigerc/src/ident_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ pub fn get_str(symbol: &Symbol) -> String {
#[derive(PartialEq, Eq, Clone, Copy, Hash)]
pub struct Symbol(u32);

impl Symbol {
pub fn new(name: &str) -> Self {
create_symbol(name)
}
}

impl Debug for Symbol {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&get_str(self))?;
Expand Down

0 comments on commit 747051f

Please sign in to comment.