Our tree structure requires that the data type used for the key has to have the PartialOrd and PartialEq traits. The &str type happens to have those traits, so we can use an &str for the key:
let mut tree: Tree<&'static str, f32> = Tree::new();
tree.set("first key", 12.65);
tree.set("second key", 99.999);
tree.set("third key", -128.5);
tree.set("fourth key", 67.21);
println!("tree.get_ref(\"third key\") is {}", match tree.get_ref("third key") {
Err(_) => {println!("Invalid!"); &0.0},
Ok(x) => x,
});
Here, we've created a Tree<&'static str, f32>, or a tree that maps static strings to 32-bit floating point numbers. If we compile and run a complete program containing that snippet, everything works beautifully...