1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// 定义一个表示终结符的结构体 #[derive(Debug, Clone)] pub struct Terminal { pub id: usize, pub name: String, } impl Terminal { pub fn new(id: usize, name: &str) -> Self { Terminal { id, name: name.to_owned() } } }