rust_lisp/model/symbol.rs
1/**
2 * A String [newtype](https://rust-unofficial.github.io/patterns/patterns/behavioural/newtype.html)
3 * representing a lisp symbol (identifier)
4 */
5#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6pub struct Symbol(pub String);
7
8impl From<&str> for Symbol {
9 fn from(s: &str) -> Self {
10 Symbol(String::from(s))
11 }
12}
13
14impl std::fmt::Display for Symbol {
15 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16 std::fmt::Display::fmt(&self.0, f)
17 }
18}