Struct Trie

Source
pub struct Trie { /* private fields */ }

Implementations§

Source§

impl Trie

Source

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}
Source

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}
Source

pub fn build_fail_point(&mut self)

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.