Crate symbol[][src]

Expand description

Simple globally interned strings.


let s1: Symbol = "asdf".into();
assert_eq!(s1, "asdf");

let s2: Symbol = "asdf".into();
let s3: Symbol = "qwerty".into();

assert_eq!(s1, s2);
assert_eq!(s1.addr(), s2.addr());

assert_ne!(s2.addr(), s3.addr());

let s4 = Symbol::gensym();
assert_eq!(s4, "G#0");

let s5: Symbol = "G#1".into();
assert_eq!(s5, "G#1");

// symbol notices that G#1 is in use
let s6 = Symbol::gensym();
assert_eq!(s6, "G#2");


An interned string with O(1) equality.