turtle/interpreter/values/symbol.rs
1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Hash)]
4pub struct Symbol(String);
5
6impl Symbol {
7 pub fn new(val: String) -> Self {
8 Self(val)
9 }
10
11 pub fn from_str(val: &str) -> Self {
12 Self(String::from(val))
13 }
14
15 pub fn string_value(&self) -> &'_ String {
16 &self.0
17 }
18}
19
20impl fmt::Display for Symbol {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 write!(f, "{}", self.string_value())
23 }
24}