#transition #hobby #table #util-lib #utilities #trie #key

no-std transition-table

transition table utilities for keyword parser

3 releases

0.0.3 Mar 13, 2022
0.0.2 Mar 2, 2022
0.0.1 Mar 1, 2022

#2463 in Rust patterns

Download history 11/week @ 2024-02-18 30/week @ 2024-02-25 12/week @ 2024-03-03 18/week @ 2024-03-10 8/week @ 2024-03-17

68 downloads per month
Used in 3 crates

MIT/Apache

8KB
142 lines

pipeline status coverage report Latest Release

Description

This package provides the definition and utilities for the trie for the const array with &str key item.

Usage

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());

Project status

This package is in the early stage.

No runtime deps