pub struct Trie { /* private fields */ }
Implementations§
Source§impl Trie
impl Trie
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/trie.rs (line 4)
3fn main() {
4 let mut trie = Trie::new();
5 trie.build(vec![
6 "openai".to_string(),
7 "stack overflow".to_string(),
8 "prompt engineering".to_string(),
9 ]);
10
11 // read from test.html
12 let read = std::fs::read_to_string("examples/test.html").unwrap();
13
14 let res: MatchResult = trie.search_replace(&read);
15
16 println!("{:?}", res.match_words);
17
18 // save res.text to test_modify.html
19 std::fs::write("examples/test_modify.html", res.modified_html).unwrap();
20}
Sourcepub fn build(&mut self, words: Vec<String>)
pub fn build(&mut self, words: Vec<String>)
Examples found in repository?
examples/trie.rs (lines 5-9)
3fn main() {
4 let mut trie = Trie::new();
5 trie.build(vec![
6 "openai".to_string(),
7 "stack overflow".to_string(),
8 "prompt engineering".to_string(),
9 ]);
10
11 // read from test.html
12 let read = std::fs::read_to_string("examples/test.html").unwrap();
13
14 let res: MatchResult = trie.search_replace(&read);
15
16 println!("{:?}", res.match_words);
17
18 // save res.text to test_modify.html
19 std::fs::write("examples/test_modify.html", res.modified_html).unwrap();
20}
pub fn build_fail_point(&mut self)
Sourcepub fn search_replace(&self, text: &String) -> MatchResult
pub fn search_replace(&self, text: &String) -> MatchResult
Examples found in repository?
examples/trie.rs (line 14)
3fn main() {
4 let mut trie = Trie::new();
5 trie.build(vec![
6 "openai".to_string(),
7 "stack overflow".to_string(),
8 "prompt engineering".to_string(),
9 ]);
10
11 // read from test.html
12 let read = std::fs::read_to_string("examples/test.html").unwrap();
13
14 let res: MatchResult = trie.search_replace(&read);
15
16 println!("{:?}", res.match_words);
17
18 // save res.text to test_modify.html
19 std::fs::write("examples/test_modify.html", res.modified_html).unwrap();
20}
Auto Trait Implementations§
impl Freeze for Trie
impl !RefUnwindSafe for Trie
impl !Send for Trie
impl !Sync for Trie
impl Unpin for Trie
impl !UnwindSafe for Trie
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more