Crates.io | transition-table |
lib.rs | transition-table |
version | 0.0.3 |
source | src |
created_at | 2022-03-01 12:40:16.598974 |
updated_at | 2022-03-13 05:51:08.817814 |
description | transition table utilities for keyword parser. |
homepage | https://gitlab.com/fton/transition-table |
repository | https://gitlab.com/fton/transiton-table |
max_upload_size | |
id | 541522 |
size | 7,555 |
This package provides the definition and utilities for the trie for the const array with &str
key item.
use ::transition_table::*;
const KEYWORDS: [(&'static str, i8); 3] = [
("A", 1),
("BB", 2),
("BBC", 3),
];
let tree = Entry::<char, _>::new(KEYWORDS.iter());
let tbl: Vec<Transition<_, _, _>> = tree.into();
let mut it = tbl.iter();
assert_eq!(it.next().unwrap(), &('C', 0usize, 0usize, 2usize));
assert_eq!(it.next().unwrap(), &('B', 0usize, 1usize, 1usize));
assert_eq!(it.next().unwrap(), &('A', 0usize, 0usize, 0usize));
assert_eq!(it.next().unwrap(), &('B', 1usize, 2usize, !0usize));
assert_eq!(it.next().unwrap(), &('\u{0}', 2usize, 4usize, !0usize));
assert!(it.next().is_none());
This package is in the early stage.