#trie #insert #hello #suggestions

easy-trie

A simple trie implementation in Rust

5 releases

0.1.4 Feb 25, 2025
0.1.3 Feb 24, 2025
0.1.2 Feb 24, 2025
0.1.1 Feb 24, 2025
0.1.0 Feb 24, 2025

#6 in #hello

Download history 286/week @ 2025-02-19 91/week @ 2025-02-26 2/week @ 2025-03-05

379 downloads per month

Apache-2.0

11KB
191 lines

Simple Trie

Github Action Crate License

This is a simple rust trie library. Essentially, I wanted to understand how to create and publish a crate so I was looking for something simple but useful.

Installation

cargo add easy-trie

Examples

Simple case

use easy_trie::trie::Trie;

let mut trie = Trie::new();
trie.insert("hello");
assert_eq!(trie.len(), 5);
assert!(trie.contains("hello"));
assert!(!trie.contains("world"));

Suggestions

use easy_trie::trie::Trie;

let mut trie = Trie::new();
trie.insert("hello");
trie.insert("help");
let suggestions = trie.suggest("h");
assert!(suggestions.contains(&"hello".to_string()));
assert!(suggestions.contains(&"help".to_string()));

No runtime deps