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

Method get

code/chapter07/bst.rs:172–193  ·  view source on GitHub ↗

获取值,和查找流程相似

(&self, key: &T)

Source from the content-addressed store, hash-verified

170
171 // 获取值,和查找流程相似
172 fn get(&self, key: &T) -> Option<&U> {
173 match &self.key {
174 None => None,
175 Some(k) => {
176 match k.cmp(key) {
177 Ordering::Equal => self.val.as_ref(),
178 Ordering::Greater => {
179 match &self.left {
180 None => None,
181 Some(node) => node.get(key),
182 }
183 },
184 Ordering::Less => {
185 match &self.right {
186 None => None,
187 Some(node) => node.get(key),
188 }
189 },
190 }
191 },
192 }
193 }
194}
195
196fn main() {

Callers 9

peekMethod · 0.45
peekMethod · 0.45
word_ladderFunction · 0.45
mainFunction · 0.45
dijkstraFunction · 0.45
get_vertexMethod · 0.45
is_adjacentMethod · 0.45
knight_tourFunction · 0.45
mainFunction · 0.45

Calls 1

cmpMethod · 0.45

Tested by

no test coverage detected