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

Method iexp

publication/code/chapter08/binary_tree.rs:265–285  ·  view source on GitHub ↗

按照节点位置返回节点组成的字符串表达式: 内部实现

(&self)

Source from the content-addressed store, hash-verified

263
264 // 按照节点位置返回节点组成的字符串表达式: 内部实现
265 fn iexp(&self) -> String {
266 let mut exp = "".to_string();
267
268 exp += "(";
269 let exp_left = match &self.left {
270 Some(left) => left.iexp(),
271 None => "".to_string(),
272 };
273 exp += &exp_left;
274
275 exp += &self.get_key().to_string();
276
277 let exp_right = match &self.right {
278 Some(right) => right.iexp(),
279 None => "".to_string(),
280 };
281 exp += &exp_right;
282 exp += ")";
283
284 exp
285 }
286}
287
288// 前中后层序遍历: 外部实现 [递归方式],

Callers

nothing calls this directly

Calls 2

to_stringMethod · 0.45
get_keyMethod · 0.45

Tested by

no test coverage detected