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

Function oexp

publication/code/chapter08/binary_tree.rs:338–347  ·  view source on GitHub ↗

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

(bt: Link<T>)

Source from the content-addressed store, hash-verified

336
337// 按照节点位置返回节点组成的字符串表达式: 外部实现
338fn oexp<T: Clone + Ord + ToString + Debug + Display>(bt: Link<T>) -> String {
339 let mut exp = "".to_string();
340 if !bt.is_none() {
341 exp = "(".to_string() + &oexp(bt.as_ref().unwrap().get_left());
342 exp += &bt.as_ref().unwrap().get_key().to_string();
343 exp += &(oexp(bt.as_ref().unwrap().get_right()) + ")");
344 }
345
346 exp
347}
348
349fn main() {
350 basic();

Callers

nothing calls this directly

Calls 4

to_stringMethod · 0.45
get_leftMethod · 0.45
get_keyMethod · 0.45
get_rightMethod · 0.45

Tested by

no test coverage detected