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

Method search

code/chapter07/avl.rs:225–246  ·  view source on GitHub ↗

数据查找

(&self, val: &T)

Source from the content-addressed store, hash-verified

223
224 // 数据查找
225 fn search(&self, val: &T) -> bool {
226 match *self {
227 Null => false,
228 Tree(ref v) => {
229 match v.val.cmp(val) {
230 Equal => { true },
231 Greater => {
232 match &v.left {
233 Null => false,
234 _ => v.left.search(val),
235 }
236 },
237 Less => {
238 match &v.right {
239 Null => false,
240 _ => v.right.search(val),
241 }
242 },
243 }
244 },
245 }
246 }
247}
248
249fn main() {

Callers

nothing calls this directly

Calls 1

cmpMethod · 0.45

Tested by

no test coverage detected