MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / word_node

Method word_node

code/chapter09/trie.rs:42–53  ·  view source on GitHub ↗

前缀字符串 wps: word_prefix_string

(&self, wps: &str)

Source from the content-addressed store, hash-verified

40 // 前缀字符串
41 // wps: word_prefix_string
42 fn word_node(&self, wps: &str) -> Option<&Node> {
43 let mut node = &self.root;
44 for c in wps.as_bytes() {
45 let index = (c - b'a') as usize;
46 match &node.children[index] {
47 None => return None,
48 Some(next) => node = next.as_ref(),
49 }
50 }
51
52 Some(node)
53 }
54}
55
56fn main() {

Callers 2

searchMethod · 0.45
start_withMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected